Run a one-time job with at

Schedule one delayed command. See the queue with atq, cancel with atrm

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

tool
cron8 commands
tags
crontroubleshooting

More cron commands

  • batch <<< '/opt/heavy-reindex.sh'

    Runs only when the load average drops below 1.5. Note: atd must be running

  • crontab -l -u <name> 2>/dev/null || echo 'no crontab'

    Check the jobs of a service account. Note: -u needs root or sudo

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

    Add an @reboot job to the current crontab. Note: the network may not be ready at boot, use systemd if you need dependencies

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

    Send stdout and stderr to journald/syslog with a tag instead of mailing root

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

    Cron has a minimal PATH. Set PATH and MAILTO at the top, or jobs fail silently

all 8 cron commands