LinuxCommandLibrary

at

Schedule commands for later execution

TLDR

Create commands interactively and execute them in 5 minutes (press when done)

$ at now + 5 minutes
copy

Create commands interactively and execute them at a specific time
$ at [hh:mm]
copy

Execute a command from stdin at 10:00 AM today
$ echo "[command]" | at 1000
copy

Execute commands from a given file next Tuesday
$ at -f [path/to/file] 9:30 PM Tue
copy

List all queued jobs for the current user (same as atq)
$ at -l
copy

View a specied job
$ at -c [job_number]
copy

SYNOPSIS

at [-V] [-q queue] [-f file] [-m|-M] [-l|-v] TIMESPEC
at [-V] [-q queue] -l [JOB ...]
at [-V] -L
at [-V] -d|-r JOB [JOB ...]

PARAMETERS

-V
    print version information and exit

-q x
    use job queue x (single letter a-z or digit 0-9; default 'a')

-f file
    read job from file instead of stdin

-m
    send email to user when job completes (if output produced)

-M
    never send email

-l
    list user's queued jobs (equivalent to atq)

-v
    verbose: report all jobs, including those without specific time

-c JOB
    print job contents to stdout

-d JOB
    delete job(s) (equivalent to atrm)

-r JOB
    delete job(s) (alias for -d)

-L
    list allowed/denied users and queues

DESCRIPTION

The at command schedules commands or scripts to execute once at a future time. It differs from cron, which handles periodic tasks, by focusing on non-recurring jobs. Users specify execution time via flexible timespec formats like '2pm tomorrow', 'now + 1 hour', 'HH:MM Dec 25', or keywords such as midnight, teatime (4pm), or noon. Relative times support units: minutes, hours, days, weeks.

Interactive use prompts for commands until EOF (Ctrl+D). The -f option reads from a file. Jobs queue under the submitter's user ID, managed by the atd daemon (must run via systemd or init). Each job receives a numeric ID per queue (default 'a'; specify with -q, e.g., 'b' for batch).

Manage jobs: list with -l (atq), verbose -v, cat contents -c, delete -d or -r (atrm). Mail notifications optional via -m. Access controlled by /etc/at.allow (whitelist) or /etc/at.deny (blacklist).

Ideal for deferred tasks like system maintenance, data processing, or reminders. Environment variables preserved; runs in submitter's shell. POSIX-standardized for portability across Unix-like systems.

CAVEATS

Requires atd daemon running; jobs fail silently if not. Time must be future; ambiguous specs may error. No recurring support (use cron). Disk quotas or resource limits affect execution. Jobs run as submitter; setuid risky.

TIMESPEC EXAMPLES

HH:MM [AM/PM], today/tomorrow/MONTHNAME DD [YYYY], now + COUNT UNIT (min/hour/day/week), midnight, noon, teatime (16:00), next Friday

JOB QUEUES

Queues partition jobs (a-z,0-9); atd processes 'a' first, then 'b' etc. 'b' often for batch (load-dependent). List queues with atq -q.

HISTORY

Originated in Unix System V Release 3 (1986); included in 4.3BSD-Tahoe. POSIX.1-2001 standardized syntax. GNU version in at package; Vixie cron variant widespread. Evolved for better queue management and daemon integration.

SEE ALSO

atq(1), atrm(1), atrun(8), cron(8), anacron(8), batch(1)

Copied to clipboard