Cheatsheet: Crontab

Last updated 2026-09-27

Field Syntax

Five fields, in order

*     *     *     *     *
│     │     │     │     │
│     │     │     │     └── day of week (0-6, Sun=0 or 7)
│     │     │     └──────── month (1-12)
│     │     └────────────── day of month (1-31)
│     └──────────────────── hour (0-23)
└────────────────────────── minute (0-59)

Any value ("every")

*

Specific value

5

List of values

1,3,5

Range of values (inclusive)

1-5

Step values (every Nth, starting from the field minimum)

*/5

Step within a range

9-17/2

Common Schedule Examples

Every minute

* * * * * /path/to/script.sh

Every 5 minutes

*/5 * * * * /path/to/script.sh

Every hour, on the hour

0 * * * * /path/to/script.sh

Every day at 2:30am

30 2 * * * /path/to/script.sh

Every weekday (Mon-Fri) at 9am

0 9 * * 1-5 /path/to/script.sh

Every Sunday at midnight

0 0 * * 0 /path/to/script.sh

First day of every month at midnight

0 0 1 * * /path/to/script.sh

Twice a day, 6am and 6pm

0 6,18 * * * /path/to/script.sh

Every 15 minutes during business hours (9am-5pm), weekdays only

*/15 9-17 * * 1-5 /path/to/script.sh

Special Strings

Run once at startup (not on a recurring schedule)

@reboot /path/to/script.sh

Once a year, Jan 1 at midnight -- same as "0 0 1 1 *"

@yearly /path/to/script.sh

Once a month, 1st at midnight -- same as "0 0 1 * *"

@monthly /path/to/script.sh

Once a week, Sunday at midnight -- same as "0 0 * * 0"

@weekly /path/to/script.sh

Once a day at midnight -- same as "0 0 * * *"

@daily /path/to/script.sh

Once an hour, on the hour -- same as "0 * * * *"

@hourly /path/to/script.sh

crontab Command

Edit your user crontab (opens $EDITOR)

crontab -e

List your current crontab

crontab -l

Remove your entire crontab

crontab -r

Back up your crontab to a file

crontab -l > backup.cron

Install a crontab from a file (replaces the current one)

crontab backup.cron

Edit another user's crontab (needs privilege)

sudo crontab -u <user> -e

Output, Logging & Environment

Discard all output (stdout and stderr)

* * * * * /path/to/script.sh > /dev/null 2>&1

Append stdout and stderr to a log file

* * * * * /path/to/script.sh >> /var/log/myjob.log 2>&1

Set an environment variable for all jobs below it

PATH=/usr/local/bin:/usr/bin:/bin
MAILTO=me@example.com
0 2 * * * /path/to/script.sh

Suppress mail-on-output for a single job

0 2 * * * /path/to/script.sh > /dev/null

System-wide cron directory for drop-in job files (no crontab -e needed)

/etc/cron.d/myjob

FAQ