What day/time does a weekly cron start on?
I had a look though the cron man but didn't find anything that helped :(
Anyone know?
I'm giving an alternative answer here even though Trevor is correct.
The cron @weekly
keyword does exactly as he mentioned. However, most distributions use run-parts
to run their own scheduled crontab files (on an hourly, daily, weekly and monthly basis) which do not make use of cron's keywords.
E.g., Ubuntu has an /etc/cron.weekly
which contains a separate file for each cronjob.
This is generally defined in /etc/crontab
Ubuntu's karmic 9.10 release has the following in /etc/crontab
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * 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 )
So the weekly crontab in Ubuntu is run at 6.47am on Sunday
Note: when looking for manpages for crontab implementations, you want to use man 5 crontab
instead of just man crontab
. The latter will only give you the syntax for the crontab command. The former gives you crontab implementation details.
@weekly is the equivalent to: 0 0 * * 0
So it'll run at 00:00 on the Sunday.
The answer lies in the manpage for the crontab itself, (man 5 crontab
):
These special time specification "nicknames" are supported, which replace the 5 initial time and date fields, and are prefixed by the '@' character:
@reboot : Run once after reboot. @yearly : Run once a year, ie. "0 0 1 1 *". @annually : Run once a year, ie. "0 0 1 1 *". @monthly : Run once a month, ie. "0 0 1 * *". @weekly : Run once a week, ie. "0 0 * * 0". @daily : Run once a day, ie. "0 0 * * *". @hourly : Run once an hour, ie. "0 * * * *".
So, it's 0 0 * * 0
, which is midnight on Sundays.
(i.e. minute 0 of hour 0 on any day of any month, as long as it's Sunday, weekday 0.)