Automating repetitive tasks with Linux schedulers
← Back to Linux Basics and DevOps Automations PageCron is a time-based job scheduler in Linux. It allows DevOps engineers to automate repetitive tasks such as backups, log cleanup, monitoring, and report generation.
* * * * * command
| | | | |
| | | | └── Day of week (0–7)
| | | └──── Month (1–12)
| | └────── Day of month (1–31)
| └──────── Hour (0–23)
└────────── Minute (0–59)
crontab -e – Edit cron jobscrontab -l – List cron jobscrontab -r – Remove all cron jobs
# Run backup every day at 2 AM
0 2 * * * /scripts/backup.sh
# Clean logs every Sunday
0 3 * * 0 /scripts/cleanup.sh
# Check disk usage every 5 minutes
*/5 * * * * /scripts/disk_check.sh