Home / Configs / Servers / crontab examples

crontab examples: schedule a script to run automatically

Run a script every minute, hour, day or week.

For Linux and macOS. Windows has no cron; use Task Scheduler there.

Cron runs commands on a schedule. Choose how often, enter the full path of your script, and copy the crontab line. Then add it with crontab -e.

Create your config file

Type your own values. The file below updates as you type, and nothing you type leaves your browser.

crontab -e
*/5 * * * *  /home/me/backup.sh >> /home/me/cron.log 2>&1

How this setup works

Diagram: crontab -e, then cron service, then Your script
crontab -e (you add a line) → cron service (checks every minute) → Your script (runs on time)

Step-by-step setup

  1. Make your script executable: chmod +x /home/me/backup.sh.
  2. Open the schedule: crontab -e.
  3. Paste the line above.
  4. Save and exit. Check with crontab -l.

What the important lines mean

Common errors and how to fix them

Job does not run
Use full paths. Cron has a small PATH, so python may not be found; write /usr/bin/python3.
Script works by hand, not in cron
Check the log file /home/me/cron.log and that the script is executable.
A line with % in the command does not work
An unescaped % in a crontab command becomes a newline, and everything after it goes to the command as input. Write \%, for example in date +\%F.
Job runs on days I did not expect
When both day of month and day of week are set (neither is *), cron runs the job when either matches. 30 4 1,15 * 5 runs on the 1st, the 15th and every Friday.
*/35 does not mean every 35 minutes
A step counts inside its own field. */35 in the minute field runs at minutes 0 and 35 of every hour, so the gap is uneven.
Last line of the crontab is ignored
Each entry must end with a newline. If the final line has none, cron treats the file as partly broken and logs a warning to syslog.

Frequently asked questions

How do I run a cron job every 5 minutes?
Use */5 * * * * followed by the command. Pick "Every 5 minutes" above to get the line.
Why is my cron job not running?
Most often the command needs a full path, the script is not executable, or it depends on environment variables cron does not have. Send the output to a log file and read it.
What do the five cron fields mean?
In order: minute, hour, day of the month, month, and day of the week. A star means every value.
How do I stop cron from sending me email?
Set MAILTO="" at the top of the crontab. With MAILTO unset, output is mailed to the crontab owner, and with an address it goes there.
What does @reboot do?
It runs the command once, after the machine reboots. Other shortcuts are @hourly, @daily, @weekly, @monthly and @yearly.
Which shell runs my command?
/bin/sh by default. Set SHELL=/bin/bash at the top of the crontab if your command uses bash features.

Written for: cron on Ubuntu 24.04, macOS 14 · Updated 2026-10-02

Free tools that help

More server configs

See all 41 config generators