When are logs rotated in Linux (using logrotate/analog)

  • logrotate@man is an entry in cron daily (actually on anacron), that ALLWAYS runs once a day
$ cat /etc/cron.daily/logrotate
...
/usr/sbin/logrotate /etc/logrotate.conf
...
  • anacron@man jobs dont allways run on the same hour … see RANDOM_DELAY and START_HOURS_RANGE
$ cat /etc/anacrontab
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22
1       5       cron.daily              nice run-parts /etc/cron.daily

$ cat /var/log/cron.1 | grep "starting logrotate"
Jan  3 03:19:01 vbox5 run-parts(/etc/cron.daily)[23355]: starting logrotate
Jan  4 03:08:01 vbox5 run-parts(/etc/cron.daily)[15843]: starting logrotate
Jan  5 03:08:01 vbox5 run-parts(/etc/cron.daily)[4828]: starting logrotate
Jan  6 03:19:01 vbox5 run-parts(/etc/cron.daily)[3977]: starting logrotate

When logrotate runs (once a day), it compares its daily/weekly/monthy in logrotate.d/file with the dates on /var/lib/logrotate.status (the last rotation), to decide whether to rotate or not

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s