#!/bin/sh
monthdate=`date +%d`
todatemysql=`date '+%y%m%d'`
yestermonthmysql=`date -d '1 day ago' '+%y%m%d'`
nowdcpaccess=`date '+%m\/%d\/%Y'`
yesterdcpaccess=`date -d '1 day ago' '+%m\/%d\/%Y'`
nowdaperror=`date '+%a %b %d'`
yesterdaperror=`date -d '1 day ago' '+%a %b %d'`
nowdmessages=`date '+%b %d'`
yesterdmessages=`date -d '1 day ago' '+%b %d'`
nowdmail=`date '+%Y-%m-%d'`
yesterdmail=`date -d '1 day ago' '+%Y-%m-%d'`
mkdir /root/govrequest/$monthdate
for i in `cat /root/govrequest/accounts`; do
touch /root/govrequest/$monthdate/$i.cpanel.log
touch /root/govrequest/$monthdate/$i.apache.log
touch /root/govrequest/$monthdate/$i.messages.log
touch /root/govrequest/$monthdate/$i.mail.log
#monthly cpbackup
pkgrund=`date +%d`
if [ "$pkgrund" -eq "27" ] || [ "$pkgrund" -eq "30" ];then
mkdir /root/govrequest/$monthdate.cpbackup
/scripts/pkgacct $i /root/govrequest/$monthdate
fi
#monthly mysql log backup
sed -n '/'$yestermonthmysql'/,/'$todatemysql'/p' /var/log/mysqld.log | grep $i >> /root/govrequest/$monthdate/$i.mysql.log
#monthly cpanel access log
sed -n '/'$yesterdcpaccess'/,/'$nowdcpaccess'/p' /usr/local/cpanel/logs/access_log | grep $i >> /root/govrequest/$monthdate/$i.cpanel.log
#monthly apache error log
sed -n "/$yesterdaperror/,/$nowdaperror/p" /usr/local/apache/logs/error_log | grep $i >> /root/govrequest/$monthdate/$i_apache.log
#monthly messages log
sed -n "/$yesterdmessages/,/$nowdmessages/p" /var/log/messages | grep $i >> /root/govrequest/$monthdate/$i.messages.log
#monthly mail log
sed -n '/'$yesterdmail'/,/'$nowdmail'/p' /var/log/exim_mainlog | grep $i >> /root/govrequest/$monthdate/$i.mail.log
done
monthdate=`date +%d`
todatemysql=`date '+%y%m%d'`
yestermonthmysql=`date -d '1 day ago' '+%y%m%d'`
nowdcpaccess=`date '+%m\/%d\/%Y'`
yesterdcpaccess=`date -d '1 day ago' '+%m\/%d\/%Y'`
nowdaperror=`date '+%a %b %d'`
yesterdaperror=`date -d '1 day ago' '+%a %b %d'`
nowdmessages=`date '+%b %d'`
yesterdmessages=`date -d '1 day ago' '+%b %d'`
nowdmail=`date '+%Y-%m-%d'`
yesterdmail=`date -d '1 day ago' '+%Y-%m-%d'`
mkdir /root/govrequest/$monthdate
for i in `cat /root/govrequest/accounts`; do
touch /root/govrequest/$monthdate/$i.cpanel.log
touch /root/govrequest/$monthdate/$i.apache.log
touch /root/govrequest/$monthdate/$i.messages.log
touch /root/govrequest/$monthdate/$i.mail.log
#monthly cpbackup
pkgrund=`date +%d`
if [ "$pkgrund" -eq "27" ] || [ "$pkgrund" -eq "30" ];then
mkdir /root/govrequest/$monthdate.cpbackup
/scripts/pkgacct $i /root/govrequest/$monthdate
fi
#monthly mysql log backup
sed -n '/'$yestermonthmysql'/,/'$todatemysql'/p' /var/log/mysqld.log | grep $i >> /root/govrequest/$monthdate/$i.mysql.log
#monthly cpanel access log
sed -n '/'$yesterdcpaccess'/,/'$nowdcpaccess'/p' /usr/local/cpanel/logs/access_log | grep $i >> /root/govrequest/$monthdate/$i.cpanel.log
#monthly apache error log
sed -n "/$yesterdaperror/,/$nowdaperror/p" /usr/local/apache/logs/error_log | grep $i >> /root/govrequest/$monthdate/$i_apache.log
#monthly messages log
sed -n "/$yesterdmessages/,/$nowdmessages/p" /var/log/messages | grep $i >> /root/govrequest/$monthdate/$i.messages.log
#monthly mail log
sed -n '/'$yesterdmail'/,/'$nowdmail'/p' /var/log/exim_mainlog | grep $i >> /root/govrequest/$monthdate/$i.mail.log
done
Comments
Post a Comment