🐧 Linux / Shell Scripting
Intermediate
How do you schedule jobs with cron?
Answer
cron is a time-based job scheduler. Jobs are defined in a crontab file. Edit with: crontab -e. Each line has the format: minute hour day month weekday command. Values: * = any, */5 = every 5, 1-5 = range, 1,3,5 = list. Examples: 0 2 * * * /backup.sh (daily at 2am), */15 * * * * /check.sh (every 15 min), 0 9 * * 1 /report.sh (Monday 9am). crontab -l lists current jobs. System-wide crons are in /etc/crontab and /etc/cron.d/. Always use full paths in cron commands since PATH is limited. Redirect output to a log: command >> /var/log/job.log 2>&1.