For logrotate I have a cron task that runs hourly.
In logrotate.conf there's the directive "daily". But the log files are rotated hourly, not daily.
Why does it happen? What's this directive for? I thought that these time-related directives are for rotating more seldom than the tool executed.
$ cat /opt/etc/logrotate.conf
compress
/opt/var/log/dir300.log {
daily
rotate 29
postrotate
killall -HUP syslog-ng
endscript
}
.
$ grep logrotate /opt/etc/crontab
50 */1 * * * admin /opt/sbin/logrotate -f /opt/etc/logrotate.conf &>/dev/null
$ ls -l dir300.log*
-rw------- 1 admin root 159856 2013-01-08 11:29 dir300.log
-rw------- 1 admin root 6838 2013-01-08 01:50 dir300.log.10.gz
-rw------- 1 admin root 20 2013-01-08 00:50 dir300.log.11.gz
-rw------- 1 admin root 592 2013-01-07 23:50 dir300.log.12.gz
-rw------- 1 admin root 124 2013-01-07 22:50 dir300.log.13.gz
-rw------- 1 admin root 20 2013-01-07 21:50 dir300.log.14.gz
-rw------- 1 admin root 20 2013-01-07 20:50 dir300.log.15.gz
-rw------- 1 admin root 107 2013-01-07 19:50 dir300.log.16.gz
-rw------- 1 admin root 20 2013-01-07 18:50 dir300.log.17.gz
-rw------- 1 admin root 20 2013-01-07 17:50 dir300.log.18.gz
-rw------- 1 admin root 20 2013-01-07 16:50 dir300.log.19.gz
-rw------- 1 admin root 14158 2013-01-08 10:50 dir300.log.1.gz
-rw------- 1 admin root 20 2013-01-07 15:50 dir300.log.20.gz
-rw------- 1 admin root 20 2013-01-07 14:50 dir300.log.21.gz
-rw------- 1 admin root 133 2013-01-07 13:50 dir300.log.22.gz
-rw------- 1 admin root 20 2013-01-07 12:50 dir300.log.23.gz
-rw------- 1 admin root 279 2013-01-07 11:50 dir300.log.24.gz
-rw------- 1 admin root 20 2013-01-07 10:50 dir300.log.25.gz
-rw------- 1 admin root 20 2013-01-07 09:50 dir300.log.26.gz
-rw------- 1 admin root 20 2013-01-07 08:50 dir300.log.27.gz
-rw------- 1 admin root 20 2013-01-07 07:50 dir300.log.28.gz
-rw------- 1 admin root 20 2013-01-07 06:50 dir300.log.29.gz
-rw------- 1 admin root 14236 2013-01-08 09:50 dir300.log.2.gz
-rw------- 1 admin root 14135 2013-01-08 08:50 dir300.log.3.gz
-rw------- 1 admin root 14349 2013-01-08 07:50 dir300.log.4.gz
-rw------- 1 admin root 14396 2013-01-08 06:50 dir300.log.5.gz
-rw------- 1 admin root 14268 2013-01-08 05:50 dir300.log.6.gz
-rw------- 1 admin root 14148 2013-01-08 04:50 dir300.log.7.gz
-rw------- 1 admin root 14347 2013-01-08 03:50 dir300.log.8.gz
-rw------- 1 admin root 14225 2013-01-08 02:50 dir300.log.9.gz
.
$ ipkg list logrotate
logrotate - 3.7.5-2 - Rotates, compresses, removes and mails system log files.
This is because you are using
-f
to force log rotation in the cron job command below:If you read
man logrotate
and look at the following paragraph:This is clear from the created files timestamp. If you look at some files like the following:
You can easily see that each execution of the cron job creates a new file. Again, this is because of the option
-f
.