Skip to content

Ubuntu — Schedule One-Time Commands with at

cron handles recurring tasks. at handles one-time execution — run a command or script once at a specific future time. Useful for a planned reboot, a delayed script run, or anything you need scheduled exactly once.


Pre-requisites

  • Ubuntu 22.04+ (or any Debian-based system)
  • sudo access

Install

sudo apt install at -y

Start and enable the atd daemon:

sudo systemctl enable --now atd

Verify:

sudo systemctl status atd

Schedule a Job

at <time>

at opens an interactive prompt. Enter the command, then press Ctrl+D to save:

at now + 10 hours
warning: commands will be executed using /bin/sh
at> reboot
at> <EOT>
job 1 at Mon May 26 08:00:00 2026

Commands requiring sudo

Prefix the command with sudo inside the at prompt as normal — the job runs under the current user's permissions.

Time formats

now + 10 minutes
now + 2 hours
now + 3 days
now + 1 week
tomorrow
5:00 AM tomorrow
10:00 PM
15:30
10:00 AM next week
next friday
01/26/2026 08:00

Read Commands from a File

at now + 2 hours < commands.txt

Each line in commands.txt is a separate command, executed in sequence.


List Scheduled Jobs

atq

at -l is an alias for the same command.

Output shows job number, scheduled time, queue, and owner:

1   Mon May 26 08:00:00 2026 a user

Inspect a Job

at -c <job_number>

Shows the full environment and commands that will be executed.


Remove a Job

atrm <job_number>

Remove all pending jobs:

for i in $(atq | awk '{print $1}'); do atrm $i; done

Common Issues

Symptom Cause Fix
bash: at: command not found Package not installed sudo apt install at
Job does not run atd not running sudo systemctl start atd
Job runs but produces no output Output goes to local mail by default Redirect output: mycommand > /tmp/out.log 2>&1