Where to start First steps track · 15 stages
Linux Labs

at — a one-time scheduled job

4 min Linux · at

Run a command once at a given time — unlike cron's recurring schedule.

Cheat sheet

6 commands Printable version
  • echo "command" | at 03:00 once at 3:00
  • at now + 30 minutes in 30 minutes
  • at -f script.sh 02:00 a script file
  • atq show the job queue
  • at -c 5 show the contents of job #5
  • atrm 5 remove job #5
  • output goes by mail — redirect it yourself: "cmd > /tmp/out 2>&1"

Overview

at runs a command once at a given time (unlike cron's repeating schedule). Handy for one-off deferred actions: reboot at night, shut down in an hour, auto-revert a firewall rule. The daemon is atd.

bash
systemctl status atd
echo "systemctl restart nginx" | at 03:00      # run at 3:00

Options

6

Below are the main flags of at, atq, atrm; the full list is in man at.

Option What it does Example
-f file Read commands from a script file instead of stdin. at -f script.sh 02:00
-l List the current user's queued jobs (same as atq). at -l
-c job_id Show the contents and environment of a queued job. at -c 5
-m Send mail to the user even if the command produced no output. at -m 03:00
-r job_id Remove a job from the queue (same as atrm). dangerous at -r 5
-q queue Put the job in a different queue (affects the nice priority it runs with). at -q b 03:00

Nothing found. Try a shorter query.

Recipes

2

Commands

bash
at 03:00                          # interactive (type commands, Ctrl+D to end)
at now + 1 hour                   # in an hour (minutes/hours/days/weeks)
at 14:30 tomorrow
at 2026-07-01                     # on a date
at -f script.sh 02:00             # run a script file
echo "cmd" | at midnight          # from a pipe
batch                             # run once the load drops (load < 1.5)

atq                               # job queue (id, time, queue)
at -c 5                           # show the contents (and environment) of job #5
atrm 5                            # remove a job (same as at -r 5)

Time formats

at 17:00              at 5pm              at now + 30 minutes
at midnight           at noon             at teatime   (16:00)
at 10:00 Jul 31       at 10am tomorrow    at now + 2 days

Access is controlled by /etc/at.allow / /etc/at.deny (who can queue jobs).

Troubleshooting

5

The job did not run

The atd daemon must be running (systemctl status atd). at's result is sent by mail to the local user (/var/mail/); stdout/stderr go there, not to a screen. Redirect it yourself: echo "cmd > /tmp/out 2>&1" | at ....

The command "was not found" inside at

Like cron, at has a minimal environment (though at does save the current env at the time the job is queued — at -c ID shows it). Absolute paths are still more reliable (see env-vars).

I need to cancel it

atq (find the id) → atrm <id>.

at: command not found / no atd

The at package isn't installed or the daemon isn't running: sudo apt install at, sudo systemctl enable --now atd.

One-off vs. recurring vs. a service

One-off — at; on a schedule — cron/systemd timers; a permanent service — a systemd unit. "When the machine is idle" — batch.

See also

  • cron — Running tasks on a schedule — classic cron and modern systemd timers.
  • background-jobs — Running things in the background, shell job control, surviving logout.
  • systemd — The init system and service manager (PID 1): units, targets, dependencies, journals.
Loading…