Linux Crontab Guide

A Linux crontab is a file of schedules, one per line, each with five time fields and a command. Build the schedule below, then learn how to install it and why cron jobs fail with a minimal environment.

Last updated: October 8, 2026

The short answer

A Linux crontab is a file of scheduled commands. Each line has five time fields followed by the command. Edit your own with crontab -e, list it with crontab -l.

# minute hour day-of-month month day-of-week  command
15 3 * * *  /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1

This runs the backup at 03:15 every day in the system time zone and appends its output to a log, which is what you want when something fails silently.

Build a Linux crontab schedule

Set the fields and the output follows Linux crontab rules, with the next runs in your time zone. Copy the result or open it in the full Generator.

Edit, list and remove a crontab

CommandWhat it does
crontab -eOpen your crontab in your editor and install it when you save.
crontab -lPrint your current crontab.
crontab -rRemove your whole crontab at once, with no confirmation by default. Some versions offer -i to ask first.

System-wide jobs live in /etc/crontab and in files under /etc/cron.d. Those lines have one extra field, the user to run as, between the five time fields and the command. The line format and field rules are in the crontab syntax reference.

Linux crontab examples

Load one into the builder above, or copy it into crontab -e followed by your command.

ExpressionWhat it doesUse
* * * * *Runs every minute.
Every minute: only for tests.
Load
*/5 * * * *Runs every 5 minutes. Load
0 * * * *Runs every hour, on the hour. Load
15 3 * * *Runs at 3:15 AM every day. Load
0 9 * * 1-5Runs at 9:00 AM every weekday (Mon-Fri). Load
30 2 * * 0Runs at 2:30 AM every Sunday. Load
0 0 1 * *Runs at 12:00 AM on day 1 of every month. Load

The environment, MAILTO and the percent sign

Cron does not start your shell profile. Jobs run with a minimal environment, a short default PATH and /bin/sh as the shell, which is why a script that works in your terminal can fail under cron. Set variables at the top of the crontab, use absolute paths, and redirect output to a log.

SHELL=/bin/bash
PATH=/usr/local/bin:/usr/bin:/bin
MAILTO=ops@example.com

# minute hour dom month dow  command
0 6 * * 1-5  cd /srv/app && ./bin/sync >> /var/log/sync.log 2>&1
30 1 * * *   /usr/bin/date +\%F >> /var/log/dates.log
  • MAILTO sends any output to that address. An empty MAILTO="" disables mail.
  • The percent sign is special: unescaped, it becomes a newline and the rest goes to the command as standard input. Write \%, as in the date line above.
  • CRON_TZ sets a time zone for the crontab in cronie. Without it, the system time zone applies.

When both day fields are set

If you restrict both day-of-month and day-of-week, cron runs the job when either matches. So 0 9 15 * 1 runs on the 15th and on every Monday. To run only on Mondays that fall in a range, schedule every Monday and test the date inside the script.

Why a cron job does not run

  1. Is the daemon running? The service is usually called cron on Debian and Ubuntu and crond on Red Hat based systems.
  2. Check the logs. Cron records each job it starts in the system log or the journal, for example in /var/log/syslog on Debian and Ubuntu. If the line is there, cron ran it and the problem is in the command.
  3. Use absolute paths for the command and for files it reads, and set PATH if the script calls other tools.
  4. Capture output with >> file 2>&1 so errors are not discarded.
  5. Escape percent signs in the command.
  6. Make the script executable and give it a shebang line, or call the interpreter explicitly.
  7. Check the schedule. Paste the five fields into the cron expression parser to see the next runs and confirm the time zone.

Sources and further reading