Linux Command: crontab
Schedule recurring tasks with cron
crontab schedules recurring tasks (cron jobs) to run automatically at specified times. Cron is the standard Linux task scheduler, used for backups, log rotation, reports, maintenance, and any periodic task. Each user has their own crontab. The cron format specifies minute (0-59), hour (0-23), day of month (1-31), month (1-12), and day of week (0-7, where 0 and 7 are Sunday). crontab provides a reliable, simple way to automate tasks. System-wide cron jobs go in /etc/crontab or /etc/cron.d/. Per-user jobs are managed with the crontab command.
Syntax
crontab [OPTION]... [FILE]Key Options
-eโ Edit your crontab-lโ List your crontab-rโ Remove your crontab-u USERโ Edit another user crontab (root only)
Examples
Edit crontab
crontab -eList cron jobs
crontab -lOutput: 0 2 * * * /usr/local/bin/backup.sh\n*/5 * * * * /usr/local/bin/check_health.sh
Every 5 minutes
*/5 * * * * /path/to/script.shPro Tips
- minute hour day-of-month month day-of-week. * means every. */5 means every 5. 1,15 means 1st and 15th.
- Cron uses minimal PATH. Always use full paths in cron jobs: /usr/local/bin/python3 instead of python3.
- Cron sends output as email. Redirect to log: >> /var/log/cron.log 2>&1. Or discard: > /dev/null 2>&1.
Learn more: Full crontab reference โ