rotate cron.daily at 2315 hours

I need to be able to rotate cron.daily on OpenSUSE 10.3 at 2315 hours every night. This is because I need to rotate my apache logs (via logrotate) at that time.

At the moment my apache logs are rotating at various different time (I guess via cron.daily).

In my root’s crontab I have put

0 23 * * * rm -f /var/spool/cron/lastrun/cron.daily

since I have read somewhere that cron.daily will start 15 minutes after I delete this file. But logs are still rotated around 1600.

cat /etc/cron.daily/logrotate

#!/bin/sh

TMPF=mktemp /tmp/logrotate.XXXXXXXXXX

/usr/sbin/logrotate /etc/logrotate.conf 2>&1 | tee $TMPF
EXITVALUE=${PIPESTATUS[0]}

if $EXITVALUE != 0 ]; then
# wait a sec, we might just have restarted syslog
sleep 1
# tell what went wrong
/bin/logger -t logrotate “ALERT exited abnormally with $EXITVALUE]”
/bin/logger -t logrotate -f $TMPF
fi

rm -f $TMPF
exit 0

cat /etc/logrotate.conf

weekly
rotate 4
create
dateext
compresscmd /usr/bin/bzip2
uncompresscmd /usr/bin/bunzip2
include /etc/logrotate.d

cat /etc/logrotate.d/apache2

/var/log/apache2/access_log {
compress
dateext
maxage 365
rotate 99
size=+4096k
notifempty
missingok
create 644 root root
postrotate
/etc/init.d/apache2 reload
endscript
}

/var/log/apache2/error_log {
compress
dateext
maxage 365
rotate 99
size=+1024k
notifempty
missingok
create 644 root root
postrotate
/etc/init.d/apache2 reload
endscript
}

/var/log/apache2/ssl-request_log {
dateext
maxage 365
missingok
create 644 root root
postrotate
/etc/init.d/apache2 reload
endscript

Thanks for any help.

This is for 11.0, I don’t know if it’s supported in 10.3:

/etc/sysconfig/cron, edit variable DAILY_TIME

Otherwise the way to do it involves making the creation time of /var/spool/cron/lastrun/cron.daily the hour and minute you want. This can be done by an at job since you don’t want to hang around to do that. :slight_smile:

To understand why creation time and not modification time, read /usr/lib/cron/run-crons, in particular the find statement.

ken yap wrote:
> This is for 11.0, I don’t know if it’s supported in 10.3:

same in 10.3, he should edit his to read:

DAILY_TIME=“23:15”


see caveat: http://tinyurl.com/6aagco
DenverD (Linux Counter 282315) via NNTP, Thunderbird 2.0.0.14, KDE
3.5.7, SUSE Linux 10.3, 2.6.22.18-0.2-default #1 SMP i686 athlon