What schedules logrotate?
I'm working on the program which creates a big log file.
I want to handle it with logrotate.
This is a configuration I put to /etc/logrotate.d/
:
/var/log/myproject.log {
hourly
maxsize 1
rotate 6
missingok
notifempty
compress
nocreate
copytruncate
su www-data www-data
}
(/var/log/myproject.log
has owner www-data
)
Commands
sudo logrotate -vf /etc/logrotate.conf
and
sudo logrotate -vf /etc/logrotate.d/myproject
rotate the log correctly.
However, after calling them /etc/cron.hourly
is empty. Which means logrotate is not called hourly.
Am I guaranteed to have
logrotate
script in/etc/cron.daily
?Does the script check for frequency of update for log files. I.e. if I have
logrotate
script in/etc/cron.daily
and for some log fileX
in/etc/logrotate.d/
I setweekly
setting, willX
be rotated daily or weekly?Can I just copy-paste
/etc/cron.daily/logrotate
to/etc/cron.hourly/
? Can I cut-and-paste?Should I add
0anacron
file to/etc/cron.hourly/
?Should I do something else to enable hourly logging?
Solution 1:
No.
-
From
man logrotate
:Each configuration file can set global options (local definitions override global ones, and later definitions override earlier ones)
So, yes.
-
Again, from the manpage:
hourly Log files are rotated every hour. Note that usually logrotate is configured to be run by cron daily. You have to change this configuration and run logrotate hourly to be able to really rotate logs hourly.
So, yes, you should move the script. Inspecting the
cron.daily
script in my system, I think moving it should work fine.