shell script to rotate logs between remote servers
cd /var/log/httpd
NOW=$(date +”%m-%d-%Y”)
mv mobile-error_log mobile-error_log-$NOW
mv mobile-access_log mobile-access_log-$NOW
/etc/init.d/httpd graceful
sleep 5
tar -cvjf /opt/logbackup/logs-$NOW.bz2 mobile-error_log-$NOW mobile-access_log-$NOW
scp mobile-access_log-$NOW domU-12-31-39-07-75-63:/clt20/uploads/mobilelog/
rm -f mobile-error_log-$NOW mobile-access_log-$NOW
Remember we have exchanged the authentication key between the two servers.
Categories: linux