ssh — guest: ~ connected
guest@ludovic.toinel.com:~$ man cron

cron — explain a cron expression and list its next run times

SYNOPSIS

cron [-n <count>] "<minute> <hour> <day-of-month> <month> <day-of-week>" cron [-n <count>] @hourly | @daily | @weekly | @monthly | @yearly

DESCRIPTION

Translates a five-field cron expression into plain English, then lists the next five times it would run, in your local time zone. A mistake in the expression is reported with the name of the field at fault.

Quotes are optional: the five fields can also be typed as five arguments.

OPTIONS

-n <count> list <count> run times instead of 5 (1 to 50)

FIELDS

minute 0-59 hour 0-23 day-of-month 1-31 month 1-12 or JAN-DEC day-of-week 0-7 or SUN-SAT (0 and 7 are both Sunday)

Each field accepts:

every value 5 one value 1,15 a list 9-17 a range /5 every 5th value 1-10/2 every 2nd value of a range 5/15 every 15th value, starting at 5

SHORTCUTS

@hourly 0 @daily 0 0 (also @midnight) @weekly 0 0 0 @monthly 0 0 1 @yearly 0 0 1 1 (also @annually)

HOW IT WORKS

cron is the Unix scheduler: every minute it compares the current time with each line of the crontab and runs the commands whose five fields all match. This command applies the same rules to compute upcoming dates.

One rule surprises everybody. When both day-of-month and day-of-week are restricted (neither starts with a star), the job runs when either matches, not both: "0 0 13 * FRI" runs on every 13th and on every Friday, not only on Friday the 13th. When one of the two is a star, only the other counts.

The run times use your browser's time zone, while a server usually runs cron in its own (often UTC) — mind the difference. A time that does not exist on a daylight-saving change day is skipped. Nothing is sent anywhere.

USE CASES

  • check what a crontab line found in a server or a CI pipeline really does;
  • write a schedule (GitHub Actions, Kubernetes CronJob, systemd-free hosts) and verify its next occurrences before deploying it;
  • find out why a job ran on an unexpected day.

NOTES

Standard five-field syntax only: no seconds or year field, no Quartz extensions (?, L, W, #), and no @reboot, which is not a schedule.

EXAMPLES

cron "/5 " cron "30 9 MON-FRI" cron "0 0 1,15 " cron -n 10 "0 8 JAN,JUL 1" cron @daily

SEE ALSO

epoch, cal, date, pomodoro, regex