What is the difference between a user crontab, `/etc/crontab`, `/etc/cron.d/` and `/etc/cron.daily/`?
IntermediateConceptcron and systemd timers
Answer
- User crontab (
crontab -e, stored in/var/spool/cron/): five time fields + command, runs as that user. /etc/crontaband/etc/cron.d/*: system files with an extra user field between the time and the command. Files incron.dare what packages and config management should drop./etc/cron.{hourly,daily,weekly,monthly}/: executable scripts run byrun-parts(via anacron on many distros). On Debian,run-partsignores filenames containing dots, sobackup.shsilently never runs; name itbackup.
# /etc/cron.d/opskit
*/5 * * * * opskit /opt/opskit/bin/opskit-health -q
More on cron and systemd timers
Explain the five cron time fields with examples.BeginnerWhat is different about the environment a cron job runs in?BeginnerHow do you prevent overlapping cron runs and capture output properly?IntermediateWhat is a systemd timer and how does it compare to cron?IntermediateWrite a minimal systemd service and timer that run a backup at 02:30 daily.IntermediateWhat is the difference between `OnCalendar=`, `OnBootSec=` and `OnUnitActiveSec=`?Advanced