PatternCron

Every Sunday at midnight

The weekly maintenance slot: 00:00 every Sunday — plus cron's oldest quirk, the day Sunday gets two numbers.

Last updated

Pattern
0 0 * * 0
Open in Crontab Schedule Creator

In plain English

  • Fires Sundays at 00:00
  • 52 runs per year

Why it’s written this way

Minute 0, hour 0, day-of-week 0: the first moment of Sunday, once a week. Weekly jobs pin day-of-week and leave day-of-month starred — the calendar date of "Sunday" changes every week, so constraining both would misfire.

Sunday is the one day with two spellings: both 0 and 7 mean it, a POSIX-vs-implementations compromise that outlived everyone involved. Most crons also accept SUN.

Edge cases to know

  • →Midnight belongs to the SERVER's timezone — for a user-facing weekly digest, midnight UTC is Saturday evening in New York and mid-morning Sunday in Sydney.
  • →A range that crosses Sunday (5-0) is invalid in classic cron — spell it 5,6,0 or 0,5,6 instead.

Part by part

0 0
The first two fields: minute 0 of hour 0. Together they mean midnight exactly, not "some time in the first hour".
* * 0
The last three fields: any day of the month, any month, and day-of-week 0 — Sunday. The two wildcards are what make it weekly rather than dated.

Common mistakes

  • * * * * 0

    A wildcard in the minute field means every minute, so instead of running once at midnight this fires 1,440 times across Sunday. It is the most expensive typo in cron.

    0 0 * * 0
  • 0 0 1 * 0

    Restricting day-of-month and day-of-week at the same time does not narrow the schedule, it widens it: classic cron ORs the two, so this runs on the 1st of every month AND every Sunday.

  • 0 0 * * Sun

    Three-letter day names are supported by Vixie cron and most Linux distributions, but not by every scheduler that accepts cron syntax — several cloud schedulers and language libraries reject them. The numeric form travels further.

Questions

Does 7 also mean Sunday in the day-of-week field?

In most implementations yes: both 0 and 7 map to Sunday, which is a convenience for people who think of the week as ending there. It is not universal, though, so 0 is the safer choice in anything portable.

Which timezone does this run in?

The one the cron daemon is configured with, which is often UTC on a server and local time on a workstation. That difference is why a weekly job appears to run on Saturday evening for some of the team — set CRON_TZ or check the daemon before assuming.

What happens if the machine is asleep at midnight on Sunday?

Standard cron simply skips the run; it has no memory of missed jobs. Use anacron for laptops and anything that is not always on, since it tracks elapsed time rather than wall-clock moments and will catch up after a wake.

How do I make it run every other Sunday instead?

Cron cannot express that on its own — its fields describe calendar positions, not intervals, and a fortnight does not divide evenly into a month. The usual answer is to keep the weekly schedule and let the script itself exit early on the weeks it should skip, checking the ISO week number for odd or even.

Is midnight the right time to schedule a weekly job?

It is the most contended minute on any shared machine, because almost every default schedule points at it. If the job is heavy, moving it a few minutes off the hour costs nothing and avoids competing with every other midnight task for disk and CPU.

Related in Patterns