How can I monitor what logrotate is doing in Ubuntu? Can the activity of logrotate be monitored?
5 Answers
cat /var/lib/logrotate/status
To verify if a particular log is indeed rotating or not and to check the last date and time of its rotation, check the /var/lib/logrotate/status file. This is a neatly formatted file that contains the log file name and the date on which it was last rotated.
Taken From:
- 973
You can try running logrotate in debug or verbose mode:
-d Turns on debug mode and implies -v. In debug mode, no changes
will be made to the logs or to the logrotate state file.
-v, --verbose
Display messages during rotation.
- 1,286
Various logs are rotated on various frequencies based on the configuration file (/etc/logrotate.conf) and/or directory (/etc/logrotate.d). Names may vary on different distributions. The configuration may specify pre and/or post rotation actions. Names of rotated files and last rotation date are in the state file (/var/lib/logrotate/state).
Logrotate does not have logging facilities. Reload/restart actions it initiates will be logged according to the logging for the program being acted on.
The easiest way to do that would be to edit /etc/cron.daily/logrotate to include the -v option. Detail about logrotate configuration and options can be found with the command man logrotate.
- 28,293
- 3
- 39
- 70
You can check the settings of logrotate, usually in /etc/logrotate.conf.
Modern distros have a specific logrotate configuration file in the /etc/logrotate.d directory.
e.g. for nginx
/var/log/nginx/*.log {
weekly
missingok
rotate 52
It will keep the file for 52 weeks (a year). The rotation is weekly.
- 376
- 5,778