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?
Best Answer
No.
From
man logrotate
:So, yes.
Again, from the manpage:
So, yes, you should move the script. Inspecting the
cron.daily
script in my system, I think moving it should work fine.