How to Schedule Tasks with Cron Jobs: A Practical Tutorial
Cron is a time-based job scheduler on Linux and macOS. It runs scripts or commands automatically at fixed intervals, making it ideal for backups, reports, and maintenance. This tutorial shows you how to create, test, and manage cron jobs.
Cron Syntax and Common Schedules
Open your user crontab with crontab -e. Each line uses five time fields followed by the command: minute, hour, day of month, month, day of week.

0 2 * * * /home/user/backup.sh— daily at 2:00 AM.*/15 * * * * /home/user/check.sh— every 15 minutes.0 9 * * 1 /home/user/report.sh— every Monday at 9:00 AM.
Step-by-Step Setup
Edit the crontab, add your job on a new line, save, and exit. Verify with crontab -l. Use absolute paths for scripts and commands.
Testing and Troubleshooting
Cron emails output if mail is configured. To log manually, redirect output: 0 2 * * * /home/user/backup.sh >> /var/log/backup.log 2>&1. Check system logs with grep CRON /var/log/syslog.
Best Practices
- Set
PATHat the top if needed. - Use
flockto prevent overlapping jobs. - Test commands in the terminal first.
Cron remains a simple, reliable way to automate repetitive tasks. Start with one job, confirm it works, then expand.