buildcron

Cron Expression for Every Sunday

The cron expression for every Sunday is 0 0 * * 0, which runs at 00:00 each Sunday. It's also what the @weekly shorthand expands to, so cron's idea of “once a week” is Sunday at midnight.

CRON → ENGLISH
0 minute0 hour* day of month* month0 day of week
VALID EXPRESSION

At 12:00am on Sunday.

0 0 * * 0

Standard 5-field crontab syntax. Day of month and day of week are OR'd when both are set.

NEXT 5 RUN TIMES · local time

What it does

Sunday is day 0, the first day of cron's week. 0 0 sets the time to midnight and the two fields after it leave the date open, so the job runs every Sunday of every month. Most crons also accept 7 for Sunday — a convenience so that 1-7 can mean Monday to Sunday — but 0 works everywhere.

Sunday runs are the classic weekly reset: compressing and rotating the week's logs, sending a “week ahead” digest, recalculating weekly rankings or quotas, clearing caches and temporary storage, or starting a long report so it's ready on Monday morning. Many Linux distributions have an /etc/cron.weekly directory whose scripts run once a week for exactly this kind of task.

Because @weekly means Sunday at midnight, a lot of weekly jobs everywhere start at the same moment. If yours doesn't need to run exactly then, choose an off-peak time like 40 4 * * 0 (04:40 on Sunday) to stay clear of the pile-up.

It also helps when reading someone else's crontab: @weekly, 0 0 * * 0 and, in most crons, 0 0 * * 7 all describe exactly the same Sunday-midnight schedule, so three different-looking lines can turn out to be the same job.

How 0 0 * * 0 works, field by field

FIELDVALUEMEANING
Minute0minute 0
Hour0hour 0 (midnight)
Day of month*every day of the month
Month*every month
Day of week0Sunday

Put together, cron reads 0 0 * * 0 as: “At 12:00am on Sunday.

To see further ahead, paste the expression into the cron calculator, which lists the next ten run times and counts how many times the schedule runs in a year.

Frequently asked questions

Is Sunday 0 or 7 in cron?

Both, in most implementations: the day of week field accepts 0 to 7, and 0 and 7 both mean Sunday. Use 0 for portability, because some schedulers only accept 0 to 6.

Is @weekly the same as every Sunday?

Yes. @weekly is shorthand for 0 0 * * 0 — midnight at the start of Sunday. For a different day or time, write the five fields out instead.

How do I run a cron job every Sunday evening?

Set the hour and minute for the evening: 0 21 * * 0 runs at 21:00 every Sunday, a good time for a job whose results should be waiting on Monday morning.