Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When do entries in cron.daily (and .weekly and .hourly) run, and is it configurable?

I haven't found a definitive answer to this, and am hoping there is one.

I'm running RHEL5 and CentOS 4, but for other distros/platforms would be great, too.

share|improve this question

9 Answers 9

up vote 64 down vote accepted

For the distributions you mention:

On CentOS 5.4 (Should be same for RHEL5)

grep run-parts /etc/crontab

01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

So cron.daily runs at 04:02am.

Same on CentOS 4.8

share|improve this answer
3  
Not to be pedantic, but that is a clear case of UUOC - sial.org/howto/shell/useless-cat :D –  Zayne S Halsall Apr 26 '10 at 20:41
1  
+1 I originally did the cat only but then realised what I had including in the output wasn't the whole file so just added the grep on as a quick edit. However, not wishing to promote the use of the useless cat I have edited my answer. Thanks –  Richard Holloway Apr 27 '10 at 7:40
1  
Is there any reason behind this? I can only assume it'd be the quietest time on the server. –  The Pixel Developer May 13 '10 at 14:55

From the man page:

 Cron also searches for /etc/anacrontab

/etc/anacrontab in my system (Fedora 12) :

1       5       cron.daily              nice run-parts /etc/cron.daily
7       25      cron.weekly             nice run-parts /etc/cron.weekly
@monthly 45     cron.monthly            nice run-parts /etc/cron.monthly

See also man anacrontab

share|improve this answer
1  
This is the case with CentOS 6. Thanks. –  mbrownnyc Jul 22 '13 at 15:59

For CentOS 6, you need to grep /etc/anacrontab and the answer varies if the server/laptop/dekstop/etc has been turned off or not.

cat /etc/anacrontab 
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days   delay in minutes   job-identifier   command
1   5   cron.daily      nice run-parts /etc/cron.daily
7   25  cron.weekly     nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly        nice run-parts /etc/cron.monthly

So, between the hours of 3AM and 10PM** (after reboot and after the machine has been up for 5 minutes^^), run /etc/cron.daily. If there is no reboot, the job should run at 3:05AM++.

** As defined by START_HOURS_RANGE
^^ As defined by FIELD_TWO (i.e. the 5 after the 1 in the cron.daily line)
++ plus a random time between 0 and 45 minutes as defined by RANDOM_DELAY

Reference: http://linux.die.net/man/5/anacrontab

share|improve this answer

For SuSE systems (specifically SLES 11.1 and openSuSE 10.3) the daily run time of the /etc/cron.daily scripts is controlled by the value of the DAILY_TIME variable set in the /etc/sysconfig/cron file.

If the DAILY_TIME variable is not set, it defaults to: (time of last boot + 15 minutes).

share|improve this answer

On Ubuntu, you'll find a file /etc/crontab, from where this is configured. I guess it is something similar on RH and Centos.

share|improve this answer
    
This is the right file for Ubuntu Lucid 10.04 LTS. My default setting is 6:25am for cron.daily. –  geekQ Aug 8 '11 at 13:46

CentOS6.x/RedHat6.x installs by default the package cronie-anacron. You have to:

yum install cronie-noanacron

yum erase cronie-anacron

Then you now have /etc/cron.d/dailyjobs to configure the best schedule time for your daily, weekly and monthly jobs.

share|improve this answer
2  
If anacron is installed, couldn't you just edit /etc/anacrontab as per other comments here instead of uninstalling it? –  cincodenada Feb 21 '13 at 20:18
    
@cincodenada That's not what Daniel Stantos is suggesting. –  mikemaccana May 14 '13 at 16:28

I use Slackware (14.0), and did not have /etc/crontab. Also, anacron is not part of the distribution.

The solution on my system was as simple as running crontab -l as root:

root@flea:~# crontab -l
# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null.  We'll do this here since these jobs should run
# properly on a newly installed system.  If a script fails, run-parts will
# mail a notice to root.
#
# Run the hourly, daily, weekly, and monthly cron jobs.
# Jobs that need different timing may be entered into the crontab as before,
# but most really don't need greater granularity than this.  If the exact
# times of the hourly, daily, weekly, and monthly cron jobs do not suit your
# needs, feel free to adjust them.
#
# Run hourly cron jobs at 47 minutes after the hour:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
#
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 4:30 on the first day of the week:
30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null
#
# Run monthly cron jobs at 4:20 on the first day of the month:
20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null
share|improve this answer

There is no such facility as far as Solaris is concerned. Just use regular crontab entries for daily tasks.

share|improve this answer

From /etc/anacrontab on my Ubuntu 9.10 system:

1       5       cron.daily       nice run-parts --report /etc/cron.daily
7       10      cron.weekly      nice run-parts --report /etc/cron.weekly
@monthly        15      cron.monthly nice run-parts --report /etc/cron.monthly
share|improve this answer

protected by Chris S Feb 6 at 20:47

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.