crontab Configuration¶
Basic Operations¶
# Edit crontab
crontab -e
# View crontab
crontab -l
# Delete crontab
crontab -r
Basic Syntax¶
Format: minute hour day month day-of-week command
# Common practical examples
0 1 * * * # Run daily at 1:00 AM
*/10 * * * * # Run every 10 minutes
0 */2 * * * # Run every 2 hours
0 9 * * 1-5 # Run weekdays at 9:00 AM
0 0 1 * * # Run on the 1st of every month at midnight
0 2 * * 0 # Run every Sunday at 2:00 AM
30 5 1,15 * * # Run on the 1st and 15th of every month at 5:30 AM
Special Characters¶
* # All values
, # Multiple values (e.g., 1,3,5)
- # Range specification (e.g., 1-5)
/ # Interval specification (e.g., */10)
Log Output Configuration¶
# Output log to file
0 1 * * * /path/to/script.sh >> /var/log/cron.log 2>&1
# No email notification
0 1 * * * /path/to/script.sh > /dev/null 2>&1
Verify cron Operation¶
# Check cron service status
systemctl status cron
# Check cron log
tail -f /var/log/cron