Cron Jobs & Task Scheduling
Objective
Hands-on practice with cron jobs & task scheduling in a Linux environment.
Tools & Technologies
croncrontabatsystemd timers
Key Commands
crontab -e0 2 * * * /usr/local/bin/backup.shat 3pm tomorrowsystemctl list-timersLab Steps
01
Crontab Syntax
Understand the five-field cron syntax: minute hour day month weekday.
02
User Crontabs
Create and edit user-level crontabs with crontab -e.
03
System Cron
Add scripts to /etc/cron.daily, /etc/cron.weekly, and /etc/cron.d/.
04
at Command
Schedule one-time tasks with the at command for deferred execution.
Challenges Encountered
- Cron uses a minimal PATH — use full paths in scripts
- Cron output goes to local mail by default — redirect to logs
Key Takeaways
- Add MAILTO='' to crontab to suppress email output
- systemd timers are more powerful and integrate with journald logging