How to achieve automatic log removal/delete/emptying of a custom app using logrotate.d config file?
I have come to the following working file:
$ sudo cat /etc/logrotate.d/appname
Code:
~/apps/appname/config/Logs/*.log {
rotate 0
weekly
maxsize 5M
maxage 30
# compress
# delaycompress
missingok
notifempty
sharedscripts
}
It empty the file (in this case all .log files in a defined directory) weekly and or earlier if the file size is 5MB+, it allows maximum age of the log lines in the file 30 days, it skips if is empty (notifempty), does not rotate by making copies (rotate 0) for archiving purpose.
To test what it does, run:
sudo logrotate /etc/logrotate.d/appname --debug
Bookmarks