tooloora

Cron every Sunday — 0 0 * * 0 explained

One run a week, Sunday at midnight — identical to @weekly, and the place where the 0-or-7 question comes up.

Runs locally — nothing is uploaded

Examples

In plain words

At 00:00, on Sundays.

Field by field

  • 0Minute

    at minute 0

    Matches: 0

  • 0Hour

    between 00:00 and 00:59

    Matches: 0

  • *Day of month

    on every day of the month

    Matches: 1, 2, 3, 4, 5, 6 … 31

  • *Month

    in every month

    Matches: Jan, Feb, Mar, Apr, May, Jun … Dec

  • 0Day of week

    on Sundays

    Matches: Sun

Next runs

Calculating the next runs …

These times apply in the time zone configured on the server. Cron converts nothing; this preview uses your device clock.

The expression stays in your browser — it is never sent to a server.

Other expressions

0 0 * * 0 runs the job once a week, on Sunday at 0:00. The last field selects the weekday, and cron counts Sunday as 0; writing 7 there means exactly the same day. The shortcut @weekly expands to this very line, which is why weekly maintenance traditionally lands in the small hours of Sunday.

Is Sunday 0 or 7 in cron?

Both. The weekday field accepts values from 0 to 7, and 0 and 7 are the same day. That is why the range 0-6 already covers the whole week and why a range like 5-7 works out as Friday, Saturday and Sunday. Ranges that wrap around, such as 6-1 for the weekend plus Monday, are not allowed — write 6,0,1 instead.

Sunday at midnight — is that the start or the end of the week?

For cron it is simply the moment when the weekday becomes Sunday, that is Saturday night rolling into Sunday. In Germany the week officially starts on Monday under ISO 8601, so a weekly report that runs at Sunday 0:00 summarises a week that is not over yet. If you want the completed week, schedule 0 3 * * 1 on Monday morning instead.

What is a weekly schedule good for?

For everything that is too expensive to run daily: full backups next to the daily incremental ones, database maintenance, index rebuilds, reports for a whole week, cleaning out old temporary files. The long gap makes monitoring more important, not less — a weekly job that fails silently is only noticed a week later, so log the exit code.

How to add the expression

  1. Decide which weekday fits: 0 for Sunday night, 1 for Monday morning when you want the completed week.
  2. Add 0 0 * * 0 plus the command, or @weekly if the schedule is unlikely to change.
  3. Pick a quiet hour if the job is heavy; Sunday 3 a.m. is emptier than Sunday midnight.
  4. Write the exit code to a log so a failed weekly run does not go unnoticed for seven days.

Frequently asked questions

Is 0 0 * * 0 the same as @weekly?

Yes. The shortcut is expanded to exactly these five fields when the crontab is read, so both run on Sunday at 0:00. Writing it out makes it easier to move the job to another weekday later.

How do I run something every two weeks?

Cron cannot express that: there is no every-other-week field. The common workaround is a weekly schedule plus a check in the script, for example running only when the ISO week number is even.

Why does my weekly job also run on the 1st?

Because the day-of-month field was restricted as well. As soon as both day fields carry a value, cron links them with OR, so a job matches when either the date or the weekday fits. Leave the day field as a star.

Does the preview of the next runs use my time zone?

It uses your device clock, because the calculation happens in your browser. On the server the same line follows the server's time zone instead, which is worth checking whenever the two differ.