How to run a cron job weekly: Sunday midnight and other weekly patterns
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.
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.
By TechCompare · Updated
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
Day-of-week numbering is where cron stops being portable. Vixie cron treats both 0 and 7 as Sunday, BusyBox only accepts 0-6, and enterprise schedulers sometimes start at Monday=1. Listing Monday through Friday as 1-5 reads cleanly, but never rely on 7 for Sunday across mixed systems. Testing the expression on the actual cron daemon is the only reliable check.
More Cron scenarios
Related guides
Frequently asked questions
How do I run a cron job once a week?
Is Sunday 0 or 7 in cron?
How do I run a cron job on weekdays only?
Related tools
Unix Timestamp
Convert between Unix timestamps and human-readable dates.
Use tool ➜CHMOD Configurator
Calculate Linux file permissions using checkboxes, octal numbers, or symbolic notation.
Use tool ➜Text Encoding Converter
Convert between Text, Base64, Binary, Hexadecimal, and Decimal formats.
Use tool ➜