Linux下自動(dòng)刪除歸檔日志文件的方法
更新時(shí)間:2016年12月15日 16:59:52 作者:huryer
這篇文章主要介紹了Linux下自動(dòng)刪除歸檔日志文件的方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧
1.日志刪除策略
自動(dòng)刪除7天前的歸檔日志與備份文件。
2.調(diào)度計(jì)劃
0 0 * * * nohup sh /db2backup/script/auto_rm_logs.sh &
3.日志刪除腳本
auto_rm_logs.sh #!/bin/sh #------------------------------------- # rm db2 archive log file and *.tgz files @hury # create @2016-12-13 # script name:auto_rm_logs.sh # 1.chmod 744 auto_rm_logs.sh # 2.crontab -e # for test only # */2 * * * * nohup sh /db2backup/script/auto_rm_logs.sh & # for official # 0 0 * * * nohup sh /db2backup/script/auto_rm_logs.sh & #------------------------------------ #params archlog_path=/db2backup/archlog backup_path=/db2backup/backup find $archlog_path -mtime +7 -name "S*.LOG" |xargs rm -f find $backup_path -mtime +7 -name "*.tgz" |xargs rm -f
相關(guān)文章
Linux?修改系統(tǒng)時(shí)間的兩種具體實(shí)現(xiàn)方式
在Linux中,有兩種常見的方式可以修改系統(tǒng)時(shí)間:更新系統(tǒng)時(shí)間的方式和手動(dòng)修改系統(tǒng)時(shí)間的方式,每種方式給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧2024-02-02Apeache啟動(dòng)不成功時(shí),用命令行檢測(cè)的方法
下面小編就為大家?guī)硪黄狝peache啟動(dòng)不成功時(shí),用命令行檢測(cè)的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-09-09Linux下PhpMyAdmin程序目錄結(jié)構(gòu)的安全管理
Linux下開發(fā)Web程序,現(xiàn)在很流行的開發(fā)方法為:用PHP開發(fā)Web程序,用Apache做Web Server,Mysql充當(dāng)后臺(tái)管理數(shù)據(jù)庫。2011-04-04