2017-07-28 71 views
0

我想每2天自動刪除tomcat日誌文件。爲此,我在/etc/logrotate.d/tomcat中編寫了一個腳本,但它不工作。我正在使用ubuntu 16.04 dist。每2天自動刪除一次tomcat日誌文件。

/opt/tomcat/logs/*.*.* { 

    daily 
    missingok 
    rotate 2 
    missingok 
    nomail 
    postrotate 
      /usr/bin/find /opt/tomcat/logs/ -name "*.*.*" -type f - 
    mtime +2 -exec rm {} \; 
    endscript 
} 

建議我回答刪除tomcat日誌。請幫忙。

+0

'的文件,但它不是working' ......什麼是實際發生的事情? (不是我的downvote) –

+0

舊的日誌文件沒有刪除 – Shekhar

回答

0

只使用一個簡單的cronjob,你執行一個簡單的bash文件從而消除在你希望的目錄

https://wiki.ubuntuusers.de/Cron/

rm -r /opt/tomcat/logs/* #or whatever you want to delete 
+0

調度crontab幫助了我。感謝markus – Shekhar

相關問題