Add, remove, list, and manage cron jobs for automation tasks. Use when user wants to schedule recurring tasks, set up automation, run scripts periodically, schedule backups, or automate any time-based task.
Manages cron jobs for task automation using the native Linux cron scheduler.
* * * * * command
│ │ │ │ │
│ │ │ │ └─── Day of week (0-7, Sun=0 or 7)
│ │ │ └───── Month (1-12)
│ │ └─────── Day of month (1-31)
│ └───────── Hour (0-23)
└─────────── Minute (0-59)
*/5 * * * *0 * * * *0 0 * * *30 2 * * *0 0 * * 00 0 1 * *0 9 * * 1-5chmod +x script.sh# Edit user's crontab
crontab -e
# Or add directly
(crontab -l 2>/dev/null; echo "SCHEDULE COMMAND") | crontab -
# List current cron jobs
crontab -l
# Check cron logs (if needed)
grep CRON /var/log/syslog
flock to prevent overlapping executions# Backup database daily at 2am
0 2 * * * /home/user/scripts/backup_db.sh >> /var/log/backup.log 2>&1
# Clean temp files every 6 hours
0 */6 * * * find /tmp -type f -mtime +7 -delete
# System health check every 15 minutes
*/15 * * * * /home/user/scripts/health_check.sh
# Weekly report every Monday at 9am
0 9 * * 1 /home/user/scripts/weekly_report.sh
systemctl status croncrontab -lgrep CRON /var/log/syslogcd in script if directory matters# Edit and remove manually
crontab -e
# Remove all cron jobs
crontab -r
# Remove specific job programmatically
crontab -l | grep -v "pattern" | crontab -