Objective

Hands-on practice with cron jobs & task scheduling in a Linux environment.

Tools & Technologies

  • cron
  • crontab
  • at
  • systemd timers

Key Commands

crontab -e
0 2 * * * /usr/local/bin/backup.sh
at 3pm tomorrow
systemctl list-timers

Lab 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