脚本写了一个死循环,根据nohup产生的日志多大, 这里表示日志超过500M之后清理, 具体数字可自定义

睡眠数可自定义

#!/usr/bin/bash
while true
do
s=`du -k nohup.out|awk '{print $1}'`
chengdatetime=`date "+%Y-%m-%d %H:%M:%S"`
if [ $s -gt 500000 ]
	then
	echo $chengdatetime":文件超过预定大小,开始清理日志"
        cat /dev/null > nohup.out
else
	echo "继续循环..."
fi
sleep 5
done

 linux判断日志文件大小进行清理

 

做个笔记。

相关文章:

  • 2021-06-17
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2021-04-11
  • 2022-02-04
猜你喜欢
  • 2022-12-23
  • 2022-01-10
  • 2022-01-04
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案