Cron lets you automate tasks like:
- backups
- scripts
- monitoring
- updates
โ๏ธ Edit Crontab
crontab -e
๐งฉ Cron Syntax
* * * * * command
โ โ โ โ โ
โ โ โ โ โโโ Day of week (0-7)
โ โ โ โโโโโ Month
โ โ โโโโโโโ Day
โ โโโโโโโโโ Hour
โโโโโโโโโโโ Minute
๐งช Examples
Run every minute:
* * * * * /script.sh
Every day at 2 AM:
0 2 * * * /backup.sh
Every Sunday:
0 3 * * 0 /cleanup.sh
๐ฆ Real Use Case: Backup Script
tar -czf backup.tar.gz /var/www
Cron:
0 1 * * * tar -czf /backup/site.tar.gz /var/www
๐ View Jobs
crontab -l
โ Common Issues
- PATH not set โ use full paths:
/usr/bin/php
- Permissions issues
- Script not executable:
chmod +x script.sh
๐ฅ Pro Tips
- Log output:
0 2 * * * /script.sh >> /var/log/script.log 2>&1
Use cron + systemd together for reliability
๐ง Summary
Cron = free automation engine built into Linux.
Once mastered, you save hours of manual work.
๐ฅ Why these are better for YOUR blog
These fit perfectly with your structure:
- Linux category = core OS knowledge
- No overlap with:
- Docker
- Reverse proxy
- DevOps pipelines