76

How can I monitor what logrotate is doing in Ubuntu? Can the activity of logrotate be monitored?

w5m
  • 151

5 Answers5

87
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:

https://www.digitalocean.com/community/articles/how-to-manage-log-files-with-logrotate-on-ubuntu-12-10

19

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.
10

In Suse Linux distros is like this:

cat /var/lib/logrotate.status
5

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.

BillThor
  • 28,293
  • 3
  • 39
  • 70
4

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.

Déjà vu
  • 5,778