Cron Expression: Cron Every Other Day
Learn how to create a cron expression for 'cron every other day'. Runs at midnight on alternating days, with the month-boundary caveat explained.
Expression Breakdown
(0-59)
(0-23)
(1-31)
(1-12)
(0-6)
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 | At minute 0 |
| Hour | 0 | At hour 0 |
| Day of Month | */2 | Every 2 days of the month |
| Month | * | Any month |
| Day of Week | * | Any day of the week |
This cron expression represents: cron every other day
Cron Expression
0 0 */2 * *
What This Expression Does
Runs at midnight on every odd-numbered day of the month — the 1st, 3rd, 5th, and so on. The */2 step in the day-of-month field starts counting from day 1, so it selects days 1, 3, 5, …, 29, 31.
The Month-Boundary Caveat
*/2 resets every month, so it is not strict “every 48 hours.” After a 31-day month, the job fires on the 31st and then again on the 1st of the next month — two consecutive days. February in a leap year does the opposite (runs on the 29th, then a one-day gap to the 1st). For most maintenance jobs this once-a-month wobble is harmless.
If exact alternation matters, run daily and let a date check decide:
0 0 * * * [ $(( $(date +\%s) / 86400 \% 2 )) -eq 0 ] && /path/to/script.sh
This runs the script only on even days since the Unix epoch, giving a true every-second-day rhythm across month boundaries. (The % signs are escaped because % is special in crontab lines.)
Use Cases
This cron schedule is commonly used for:
- Backups where daily is overkill but weekly is too sparse
- Rotating or vacuuming medium-sized database tables
- Syncing datasets that change slowly
- Certificate or dependency freshness checks
How to Use
- Copy the cron expression above
- Open your crontab with
crontab -e - Add a new line with:
0 0 */2 * * /path/to/your/script.sh - Save and exit
Alternative Formats
-
Every other day at 6am instead of midnight:
0 6 */2 * * -
Odd days explicitly:
0 0 1-31/2 * *(same behavior as*/2) -
Even days of the month:
0 0 2-30/2 * *