%cat cutlog.sh
#!/bin/sh
date=`date -v +0d +%Y%m%d%H%M%S`
logpatch=`pwd`
bakpatch=/var/log/logbak
mv $logpatch/$1 $bakpatch/$date.log && tail -100 $bakpatch/$date.log >$logpatch/$1
if [ $? -eq 0 ];then
echo bak seccessful
else
echo bak failed
fi
以下为最新使用中的,做了一些改动:
date=`date -v +0d +%Y%m%d%H%M%S`
logpatch=`pwd`
bakpatch=/var/log/logbak
filename=`echo $1 | awk -F"." '{print $1}'`
mv $logpatch/$1 $bakpatch/$filename\_$date.log && tail -100 $bakpatch/$filename\_$date.log >$logpatch/$1
if [ $? -eq 0 ];then
echo bak seccessful
else
echo bak failed
fi
阅读(933) | 评论(1) | 转发(0) |