Search This Blog

Sunday, 11 October 2009

Script for moving system logs to another machine by using with time stamp using crontab

#this is the simple script which run depends on crontab entry
TIMESTAMP=`date +"%b_%d_%y_%H-%M%p"`
cd /var/adm
cp messages.1 messages.$HOST.$TIMESTAMP
sleep 6
gzip /var/adm/messages.$HOST.$TIMESTAMP
scp /var/adm/messages.$HOST.$TIMESTAMP.gz root@ #ssh key must be instlled on remote machine, else, it will ask for the password everytime.
rm /var/adm/messages.$HOST.$TIMESTAMP.gz

No comments:

Post a Comment