at — Schedule One-Time Commands for Later Execution

Practical guide to at — schedule one-time commands for a specific time, pipe jobs in, manage them with atq and atrm, and run batch when system load is low.

at runs a command not on a schedule but exactly once at a later point in time – perfect for one-off maintenance, a delayed reboot or a quick reminder. Time specifications are remarkably flexible: a clock time, now + 30 minutes or simply tomorrow. It relies on the atd daemon running in the background, and you manage queued jobs with atq and atrm. When you'd rather wait until the machine is idle, reach for batch.

Schedule Jobs

at <time> — Open interactive prompt to enter commands for scheduled execution.

at 10:00

echo '<command>' | at <time> — Schedule a command non-interactively.

echo 'backup.sh' | at 02:00

at -f <script> <time> — Schedule a script file for execution.

at -f /home/user/maintenance.sh 23:00

at now + <number> <unit> — Schedule relative to current time.

echo 'reboot' | at now + 30 minutes

Time Formats

at 14:30 — Run at a specific time today (or tomorrow if past).

echo 'echo done' | at 14:30

at 2:00 PM — 12-hour format with AM/PM.

echo 'echo done' | at 2:00 PM

at noon — Run at noon.

echo 'run-report.sh' | at noon

at midnight — Run at midnight.

echo 'cleanup.sh' | at midnight

at 10:00 Jan 15 — Run at a specific date and time.

echo 'deploy.sh' | at 10:00 Jan 15

at now + 1 hour — Run in one hour (units: minutes, hours, days, weeks).

echo 'check-status.sh' | at now + 1 hour

at tomorrow — Run at the same time tomorrow.

echo 'reminder.sh' | at tomorrow

Manage Jobs

atq — List all pending at jobs for the current user.

atq

at -l — List pending jobs (same as atq).

at -l

at -c <job-id> — Show the content/commands of a scheduled job.

at -c 5

atrm <job-id> — Remove a scheduled job.

atrm 5

at -d <job-id> — Delete a scheduled job (same as atrm).

at -d 5

batch Command

batch — Schedule a job to run when system load is low (< 1.5).

echo 'heavy-task.sh' | batch

batch -f <script> — Schedule a script for execution when load permits.

batch -f /home/user/rebuild-index.sh

Common Patterns

echo 'systemctl restart nginx' | at 03:00 — Schedule a service restart during off-hours.

echo 'sudo systemctl restart nginx' | at 03:00

echo 'wall "Maintenance in 10 minutes"' | at now + 50 minutes — Schedule a broadcast warning message.

echo 'wall "Server rebooting in 10 minutes"' | at now + 50 minutes

at -M <time> — Suppress mail notification after job completion.

echo 'cleanup.sh' | at -M 02:00

at -m <time> — Send mail to user even if job produces no output.

echo 'important-task.sh' | at -m 14:00

Conclusion

at is the right tool when a command needs to run exactly once at a later time – anything recurring still belongs to cron. Remember that jobs only fire while the atd daemon is running, and that /etc/at.allow and /etc/at.deny decide who may queue jobs at all. Output and errors are delivered to the user by local mail by default, so check atq and your mailbox if a scheduled job appears to have done nothing.

Further Reading

  • at(1) man page – official manual page for at, atq, atrm and batch
  • Ubuntu manpage: at – Ubuntu's manual page for scheduling one-time jobs with at and batch
  • crontab – schedules recurring tasks via the cron table
  • systemctl – controls systemd services and timers as a modern scheduling alternative
  • nohup – keeps commands running after you log out