Run job at boot

Append @reboot job idempotently; note: no networking guarantee at boot, use systemd for deps

( crontab -l 2>/dev/null; echo '@reboot /usr/local/bin/warmup.sh' ) | crontab -

tool
cron8 commands
tags
crongitops

More cron commands

  • */5 * * * * /opt/job.sh 2>&1 | /usr/bin/logger -t job

    Tag stdout+stderr into journald/syslog instead of mailing root

  • crontab - <<'EOF' MAILTO=ops@example.com PATH=/usr/local/bin:/usr/bin:/bin 0 3 * * * backup.sh EOF

    Cron PATH is minimal; set PATH/MAILTO at top or jobs fail silently

  • run-parts --test /etc/cron.daily

    List which scripts would execute without running them; debugging cron.daily

  • systemd-run --on-calendar='*-*-* 03:00:00' --unit=backup /opt/backup.sh

    modern: transient OnCalendar timer with logs/retries; replaces a crontab line

  • at now + 1 hour <<< 'systemctl restart nginx'

    Schedule a single deferred command; inspect queue with atq, cancel with atrm

all 8 cron commands