Crontab Tutorial

cron runs commands on a schedule. User cron entries are edited with crontab.

Edit the current user crontab

crontab -e

Crontab format

* * * * * command-to-run
│ │ │ │ │
│ │ │ │ └── day of week
│ │ │ └──── month
│ │ └────── day of month
│ └──────── hour
└────────── minute

Run a script every day at 2:30 AM

30 2 * * * /home/user/scripts/backup.sh

List existing cron jobs

crontab -l

Use full paths inside cron jobs because the environment is usually smaller than an interactive shell.

Leave a Comment