If the five-star syntax feels too complex, cron provides "nicknames" for common intervals: @reboot : Run once, at startup. @daily : Run once a day (midnight). @weekly : Run once a week (Sunday midnight). @monthly : Run once a month (1st of the month). @reboot /home/user/scripts/start-web-server.sh Use code with caution. Three Pro-Tips for Success
crontab -e : Edit your crontab file (opens in your default text editor). crontab -l : List all your active scheduled tasks. crontab -r : Remove all your scheduled tasks. Practical Crontab Examples 1. Run a script every minute The most basic heartbeat for a system. * * * * * /home/user/scripts/heartbeat.sh Use code with caution. 2. Schedule a daily backup at 2:30 AM crontab example
Running heavy tasks in the middle of the night avoids slowing down users during the day. 30 2 * * * /usr/bin/python3 /home/user/backup.py Use code with caution. 3. Run a command every Sunday at 5 PM Great for weekly maintenance or report generation. 0 17 * * 0 /home/user/scripts/weekly-report.sh Use code with caution. 4. Run a task every weekday at 9 AM Perfect for firing off "start of workday" notifications. 0 9 * * 1-5 /home/user/scripts/office-init.sh Use code with caution. 5. Execute every 15 minutes The slash / denotes an interval. */15 * * * * /home/user/scripts/check-temp.sh Use code with caution. 6. Run twice a day (e.g., 10 AM and 10 PM) The comma , allows you to list specific times. 0 10,22 * * * /home/user/scripts/sync-data.sh Use code with caution. Using Special Shortcuts If the five-star syntax feels too complex, cron
Automating repetitive tasks on Linux or Unix-based systems is a superpower, and the tool behind it is . If you’ve ever wanted your server to back up its database at midnight or clear out temporary files every Sunday, you need to master crontab . @monthly : Run once a month (1st of the month)