How to run a cron job weekly: Sunday midnight and other weekly patterns

0 0 * * 0 runs a job every Sunday at midnight. The fifth field (0-6 or 0-7 depending on the cron implementation) controls the day of the week. Sunday is 0 (and sometimes 7), Monday is 1, Saturday is 6. This is the pattern for weekly reports, SSL certificate renewal checks, and full backups.

Schedule pattern
Weekly schedule
weekly
Category
Common Patterns
Standard cron expression patterns

How this is calculated

Different cron implementations number weekdays differently. Vixie cron (standard Linux) uses 0-7 where both 0 and 7 are Sunday. BusyBox cron uses 0-6 where 0 is Sunday. Some enterprise schedulers use 1-7 where 1 is Monday. When writing portable cron expressions, avoid relying on 7 for Sunday. For multiple days, list or range them: 0 0 * * 1-5 runs Monday through Friday. For every other day, cron alone can't express that cleanly. Use a wrapper script that checks the date.

Verdict

0 0 * * 0 for weekly Sunday execution is the safest portable choice. If weekday numbering ambiguity matters (containers, embedded systems), test the expression on the target cron daemon before deploying to production.

More Cron scenarios

Frequently asked questions

What is a Cron Job?
A cron job is a scheduled task that runs automatically on a Unix-like operating system (like Linux or macOS) at specific intervals. It is heavily used by developers to run background tasks like database backups, cache clearing, or sending nightly emails.
What do the 5 parts of a cron expression mean?
From left to right, the 5 fields are: Minute (0-59), Hour (0-23), Day of the Month (1-31), Month (1-12), and Day of the Week (0-6, where 0 and 7 are Sunday).
What does the asterisk (*) mean in Cron?
The asterisk acts as a wildcard, meaning 'every'. For example, if the minute field is an asterisk, the task runs every single minute. If the month field is an asterisk, the task runs every single month.
How do I run a task every 5 minutes?
To run a task every 5 minutes, use the slash operator in the minute field like this: */5 * * * *. The */5 means 'every 5th minute'.