nohup.out追加日誌的文件,文件太大自動清零的腳本
阿新 • • 發佈:2018-06-20
檢測 5.6 ins web ron 綠色 code null bin
1 #!/bin/bash 2 # clean the nohup.out file of list_domain 3 # author by:guoqian 4 # date:2018-06-19 5 6 path="/home/weblogic/Oracle/Middleware/user_projects/domains/list_domain/bin" 7 8 if [ $# -eq 0 ];then 9 cd $path 10 file_size=`du -sm nohup.out| awk ‘{print $1}‘` 11 12 if [ $file_size -ge 2000];then 13 /bin/cp /dev/null nohup.out 14 echo "$(date +%F‘ ‘%X) :The file size $file_size M , clean it over!" >> $path/clean_nohup.out.log 15 else 16 echo "$(date +%F‘ ‘%X) :The file size $file_size M , not clean it !" >> $path/clean_nohup.out.log 17 fi 18 exit 119 else 20 echo "Don‘t take parameters !" 21 fi
定時任務:0 0 * * 0,3 /home/weblogic/Oracle/Middleware/user_projects/domains/list_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時,會自動清零,且不會影響系統正常運行。
24小時綠色聯系通道:
QQ:418892106
E-mail:[email protected]
nohup.out追加日誌的文件,文件太大自動清零的腳本