1

I have Ubuntu 12.04.2 LTS server.

My daily log rotations which are listed under /etc/logrotate.d/ are executed at the morning around 7:00 am, but it is not on exact time, each day it changed on range of (07:00 - 07:25), How can I prevent the random time execution of log rotation?

/etc/crontab file content:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 0 7 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

/etc/cron.daily/logrotate content:

\#!/bin/sh

# Clean non existent log file entries from status file cd /var/lib/logrotate test -e status || touch status head -1 status > status.clean sed 's/"//g' status | while read logfile date do [ -e "$logfile" ] && echo ""$logfile" $date" done >> status.clean mv status.clean status

test -x /usr/sbin/logrotate || exit 0 /usr/sbin/logrotate /etc/logrotate.conf

Related thread: Specify the time of daily log rotate

Ricardo
  • 139
Khaled Zoabi
  • 11
  • 1
  • 4

1 Answers1

2

The /etc/cron.daily folder contains dozens of items (17 items in my box), and logrotate is not guaranteed to run at first.

So if you want logrotate to run exactly the same time everyday, make it as a single entry in the crontab as in the Related thread: Specify the time of daily log rotate

Ricardo
  • 139
Ben Lin
  • 317
  • 2
  • 4