How can I execute logRotate daily at a specific time (3h30) each day? Specific details on how to do this would be appreciated.
I'm on Debian.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You can create a file such as this:
$ sudo gedit /etc/cron.d/logrotate
And add these lines to this file:
#!/bin/bash /usr/sbin/logrotate /etc/logrotate.conf EXITVALUE=$? if [ $EXITVALUE != 0 ]; then /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]" fi exit 0
Then create a crontab entry that runs this script at 3h30 each day. To do this 2nd step edit the file
$ sudo gedit /etc/crontab
And add this line:
# m h dom mon dow user command 30 3 * * * root /etc/cron.d/logrotate
NOTE: You might need to omit the user in some situations, like this:
# m h dom mon dow command 30 3 * * * /etc/cron.d/logrotate
Lastly make the
logrotate shell script (
$ sudo chmod +x /etc/cron.d/logrotate