Scheduling in Linux: cron and crontab

Updated November 1, 2026

cron runs commands on a schedule, and each user edits their own schedule with crontab -e.

Syntax

crontab -e   # minute hour day month weekday command

Common cases

crontab -e                   # open your schedule in an editor
crontab -l                   # show your jobs
# example schedule lines:
0 3 * * *   /path/backup.sh   # every day at 03:00
*/15 * * * * /path/check.sh   # every 15 minutes
0 9 * * 1   /path/report.sh   # Mondays at 09:00

Sample output

$ crontab -l
* * * * * date >> /tmp/tick.log
* * * * * backup.sh
$ tail -2 /tmp/tick.log
Sun Jul 26 04:17:01 UTC 2026
Sun Jul 26 04:18:01 UTC 2026
$ journalctl -u cron -n 5 --no-pager
Jul 26 04:18:01 srv1 CRON[366]: (root) CMD (backup.sh)
Jul 26 04:18:01 srv1 CRON[367]: (root) CMD (date >> /tmp/tick.log)
Jul 26 04:18:01 srv1 CRON[364]: (CRON) info (No MTA installed, discarding output)
Jul 26 04:18:01 srv1 CRON[364]: pam_unix(cron:session): session closed for user root
Jul 26 04:18:01 srv1 CRON[365]: pam_unix(cron:session): session closed for user root

How it works: the five time fields

A schedule line starts with five fields: minute, hour, day of month, month, day of week. A star * means 'any value', */15 means 'every 15'; comma lists and dash ranges work too. cron is a service: it checks the schedules once a minute and runs whatever is due. cron has a very bare environment (a short PATH), so in jobs you write full paths to commands and files. systemd has its own replacement - timers (systemctl list-timers).

Common mistakes

The line (root) CMD (backup.sh) in the log says one thing only: cron started the command. It says nothing about success. Whatever the job printed, cron tries to send by mail, and a server usually has no mail agent - next to it you get (CRON) info (No MTA installed, discarding output), and the output together with the errors is gone. That is why a job is written as backup.sh >> /tmp/backup.log 2>&1.

cron does not read ~/.profile or ~/.bashrc. A script in ~/bin that you start by name in your terminal is not found from cron: the job log gets /bin/sh: 1: backup.sh: not found. For the same reason cron cannot see node or python installed by a version manager. Write the full path: /home/dev/bin/backup.sh.

A percent sign in a schedule line is not a plain character. Everything after the first % cron hands to the command on standard input instead of the command line. The job * * * * * date +%F > /tmp/pct.log 2>&1 creates no file at all: the redirect became text and the command was left as date +. Escape it with a backslash: date +\%F.

In the book

This topic is covered in full in the chapter Scheduling tasks.

See also

Services: systemctl.