#/bin/sh
curdate=`date -d -1day +%Y%m%d` #时间
source=/data/apps/route/nohup.out #路径
target=/data/apps/route/log/nohup"$curdate"_ #切割完的路径
fileSize=`ls -l $source |awk '{print $5}'`
#10m #计算方式 1M=1024*1024
# nohup.log 超过10m 日志切割
threshSize=10485760
if [ "$fileSize" -gt "$threshSize" ];then
echo "lograte cut log..."
split -C 10m -d -a 5 $source $target
cat /dev/null > $source
#清理30天前nohup 文件
#find /data/apps/route/log/ -type f -mtime +30 -name /home/fdm/log/tmp/nohup* -exec rm -f {} \;
#rm -f /home/eno/log/tmp/nohup*
fi
配置定时任务
0 0 * * * /bin/sh /data/apps/route/lograte.sh
每天定时日志切割脚本
最新推荐文章于 2024-02-05 15:09:33 发布