1. 1 #!/bin/bash
  2. 2 # clean the nohup.out file of domain
  3. 3 # author by:guoqian
  4. 4 # date:2018-06-19
  5. 5
  6. 6 path="/home/weblogic/Oracle/Middleware/user_projects/domains/domain/bin"
  7. 7
  8. 8 if [ $# -eq 0 ];then
  9. 9 cd $path
  10. 10 file_size=`du -sm nohup.out| awk \'{print $1}\'`
  11. 11
  12. 12 if [ $file_size -ge 2000 ];then
  13. 13 /bin/cp /dev/null nohup.out
  14. 14 echo "$(date +%F\' \'%X) :The file size $file_size M , clean it over!" >> $path/clean_nohup.out.log
  15. 15 else
  16. 16 echo "$(date +%F\' \'%X) :The file size $file_size M , not clean it !" >> $path/clean_nohup.out.log
  17. 17 fi
    19 else
  18. 20 echo "Don\'t take parameters !"
  19. 21 fi

定时任务:0 0 * * 0,3 /home/weblogic/Oracle/Middleware/user_projects/domains/domain/bin/clean_nohup.out.sh > /dev/null 2>&1

1.此脚本用于清零自动追加日志的文件nohup.out

2.此脚本已在Red Hat Enterprise Linux Server release 5.6 (Tikanga)系统上经过测试通过。

3.此脚本写入crontab定时任务,每周三,周日晚上零点会自动检测,nohup.out文件大于2G时,会自动清零,且不会影响系统正常运行。

4.24小时绿色联系通道:QQ:418892106    E-mail:418892106@qq.com

版权声明:本文为guoqian原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/guoqian/p/9203295.html