Skip to content

Cron schedule syntax

How the five cron fields work, with ready-to-use examples for backups, reports and maintenance jobs.

4
Sections
1 min
Read time

Cron runs commands on a schedule on Linux servers, and control panels use the same format for their scheduled tasks.

The five fields

┌──────── minute (0-59)
│ ┌────── hour (0-23)
│ │ ┌──── day of month (1-31)
│ │ │ ┌── month (1-12)
│ │ │ │ ┌ day of week (0-7, 0 and 7 are Sunday)
│ │ │ │ │
* * * * *  command
SymbolMeaningExample
*Every value* in hours = every hour
,A list1,15 = the 1st and the 15th
-A range1-5 = Monday to Friday
/A step*/10 in minutes = every 10 minutes

Examples

ScheduleWhen it runs
*/5 * * * *Every 5 minutes
0 * * * *At the start of every hour
30 2 * * *Every day at 02:30
0 9 * * 1-5Weekdays at 09:00
0 3 * * 0Sundays at 03:00
0 0 1 * *Midnight on the first of each month

Editing and checking

crontab -e     # edit your jobs
crontab -l     # list your jobs

Avoiding surprises

  • Cron runs with a minimal environment: use full paths to programs and files.
  • The time is the server's timezone, which may not be yours.
  • Send output to a log file so failures are visible, e.g. >> /var/log/backup.log 2>&1.
  • Spread heavy jobs out instead of starting them all at midnight.