This post was originally published on go2linux.org on August 6, 2008. The domain is no longer mine, but I am the original author. I am republishing it here on garron.me with corrections and improvements.

Introduction

The at command schedules a command or script to run once at a specific time in the future. Unlike cron, which runs jobs on a recurring schedule, at is for one-time deferred execution — run this once, at that time.

Installation

On Debian and Ubuntu:

sudo apt-get install at

The atd daemon must be running for at to work:

sudo systemctl enable --now atd

Basic usage

Read commands from a file:

at now + 5 minutes < $HOME/commands.txt

Or enter commands interactively. Type at <time> and press Enter. You will see the at> prompt. Type each command on a new line. Press Ctrl+D when done:

$ at now + 1 hour
at> echo "Job done" | mail -s "Done" [email protected]
at> <EOT>
job 3 at Mon Jun  8 15:00:00 2026

Time formats

at accepts many flexible time expressions:

| Expression | Meaning | |---|---| | now + 5 minutes | 5 minutes from now | | now + 2 hours | 2 hours from now | | now + 3 days | 3 days from now | | noon | Today at 12:00 | | midnight | Tonight at 00:00 | | teatime | Today at 16:00 | | 2:30 PM | Today at 14:30 | | 10:00 AM tomorrow | Tomorrow at 10:00 | | 10:00 Jun 15 | June 15 at 10:00 | | DD.MM.YY | Specific date |

Managing queued jobs

List pending jobs:

atq

Remove a job by its ID:

atrm 3

Inspect the commands of a job:

at -c 3

Practical example: shut down after a delay

echo "shutdown -h now" | at now + 30 minutes

Useful when you start a long download and want the machine to power off automatically when you leave.

Modern alternative: systemd-run

On systems running systemd (most modern Linux distributions), systemd-run provides similar one-shot scheduling without needing the atd daemon:

systemd-run --on-active=30m shutdown -h now

This schedules a shutdown in 30 minutes. To cancel it, find the transient unit name with systemctl list-timers and stop it:

systemctl stop run-NNNNN.timer

at remains the more portable choice — it works on systems without systemd, its time syntax is more human-readable, and it integrates with the system mail for job output.

Notes

  • at jobs run in a non-interactive environment. Make sure commands use full paths or set PATH explicitly inside the script.
  • Output from the job is emailed to the user by default unless redirected.
  • batch is a related command that runs jobs when the system load drops below a threshold.
  • See man at for the full list of time format options.