Tuesday, February 22, 2011

log clear automatically


#!/bin/bash
remote_user=root
remote_address=192.168.100.200
ssh $remote_user@$remote_address "sh /mnt/raid1/j/avmper/clean/logclear_openfiler.sh"

#!/bin/bash
todaydate=`date +%F`
if [ ! -d "/mnt/raid1/j/avmper/log/$todaydate" ];then
echo "welcome to log clear process"
echo "\n now script take backup"
cp -rf /var/log/ /mnt/raid1/j/avmper/log/$todaydate
find /var/log/ -type f -not \( -name "*.gz" \) > /mnt/raid1/j/avmper/log/$todaydate/folderfilelist
echo "script clear all log files of /var/log/"
for i in `cat /mnt/raid1/j/avmper/log/$todaydate/folderfilelist`
do
cat /dev/null > $i;
done
echo " \n log clear process is successfully completed "
else
echo "log clear of $todaydate process is already done it"
fi

No comments:

Post a Comment