How to change the day of the week Logrotate shifts the file when configured weekly?
Changing the time of running weekly cron jobs won't help, for the reasons you stated.
Note what the manpage of logrotate
says about weekly
rotation:
weekly Log files are rotated if the current weekday is less than the
weekday of the last rotation or if more than a week has passed
since the last rotation. This is normally the same as rotating
logs on the first day of the week, but it works better if
logrotate is not run every night.
That's why it tends to rotate on Mondays.
What you can do, is to run a special, separate instance of logrotate
on Wednesdays, which only runs for the Google logs. For example, create /etc/logrotate-google.conf
, containing the configuration you have specified, and create a cron job that runs on Wednesdays (as root, so use /etc/crontab
, or /etc/cron.d
):
46 6 * * 3 root logrotate /etc/logrotate-google.conf
Related videos on Youtube
dragosrsupercool
Updated on September 18, 2022Comments
-
dragosrsupercool over 1 year
I have following configuration which rotates all content of google folder weekly:
/var/log/google/*.log { create 0777 www-data www-data weekly missingok rotate 90 compress delaycompress notifempty olddir /var/log/google/old }
Now the thing is it does it rotation every Monday morning while I want to do the weekly rotation every Wednesday.
I was thinking to change the following entry in crontab:
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
But I am confused if this will work, because I could find
logrotate
in/etc/cron.daily
and not in/etc/cron.weekly
.Is it possible to change files on Wednesday than Monday? If yes then how?
-
Doug Smythies over 7 yearsSunday is day 0, and so weekly log rotation is supposed to occur on Sunday.