2013-07-25

What time do scripts in /etc/cron.daily run?

I put a script in /etc/cron.daily and would like to know what time it will run. And, more importantly, how does the system determine this time value?

On SUSE Linux Enterprise and openSUSE, the time is determined by the CRON_DAILY parameter in the /etc/sysconfig/cron file. If this parameter is not set, it defaults to 15 minutes after the time of the last boot.

Because of how the mechanism for running scripts in the /etc/cron.{houry,daily,weekly,monthly} directories works, the time value must be a multiple of 15 minutes (i.e. 0, 15, 30, or 45 minutes past the hour). The exact functioning of this mechanism can be seen by studying the following:
# cat /etc/crontab
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
# check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly
#
-*/15 * * * *   root  test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1

This basic cronjob simply runs /usr/lib/cron/run-crons every 15 minutes. The real magic happens inside that script.

A nice discussion of how cron works in SUSE/openSUSE is available in the Support Data Base (SDB): http://en.opensuse.org/SDB:Cron

1 comment:

  1. Anonymous00:30

    ...and edit the start of the daily cron job in /etc/sysconfig/cron on openSUSE. The variable is called DAILY_TIME there (you can use YaST to change the setting, if you like - I prefer my 'vi'.

    ReplyDelete