Operations 9 min read

Master Linux ‘at’ Command: Schedule One‑Time Tasks Easily

Learn how to install, configure, and use the Linux ‘at’ command to schedule one‑time tasks, including interactive entry, piping commands, time expressions, viewing and removing jobs, and comparing it with cron for efficient, non‑recurring automation.

ITPUB
ITPUB
ITPUB
Master Linux ‘at’ Command: Schedule One‑Time Tasks Easily

Installation and daemon activation

Most Linux distributions ship the at utility. Verify its presence with:

at -V
# Example output
at version 3.1.13

If the command is not found, install the at package using your distro's package manager (e.g., apt install at, yum install at, pacman -S at).

After installation start the atd daemon so scheduled jobs can run. On systemd‑based systems enable it immediately and ensure it starts on boot:

sudo systemctl enable --now atd

Basic syntax

The general form is: at [options] [date‑time] Options -f <file>: read commands from <file> instead of stdin. -q <queue>: assign the job to a specific queue (a‑z, A‑Z). -l: list pending jobs (same as atq). -d <jobid> or -r <jobid>: delete the specified job. -m: mail the user when the job finishes.

Parameter date‑time: the exact moment the job should be executed. Accepts many absolute and relative formats (see the "Time expressions" section).

Interactive scheduling

Enter the at command followed by the desired time. The shell then prompts with at> where you type the commands to be executed. Finish the input with an end‑of‑file (Ctrl‑D). Example:

at 11:20 AM
warning: commands will be executed using /bin/sh
at> echo "hello world" > ~/at-test.txt
at> ^D   # Ctrl‑D sends EOF
job 3 at Mon Jul 26 11:20:00 2021

After the scheduled time, verify the result:

cat ~/at-test.txt
hello world

Non‑interactive (pipeline) scheduling

You can feed a command string to at via a pipe, avoiding the interactive prompt:

echo "echo 'hello again' >> ~/at-test.txt" | at now + 1 minute

One minute later the file contains both lines:

cat ~/at-test.txt
hello world
hello again

Supported time expressions

at

understands a wide range of absolute and relative specifications:

Absolute numeric forms: YYMMDDhhmm[.ss] (e.g., 2307311230) and CCYYMMDDhhmm[.ss].

Keywords: now, midnight, noon, teatime (4 PM), AM, PM.

Human‑readable words: noon, midnight, tomorrow, next week, etc.

Relative expressions using + followed by a number and a unit: minutes, hours, days, weeks, months, years. Example: now + 3 days.

Example commands:

# Run rsync tomorrow at 3:30 AM
echo "rsync -av /home/tux me@myserver:/home/tux/" | at 3:30 AM tomorrow

# Execute a script on a specific calendar date
echo "/opt/batch.sh ~/Pictures" | at 3:30 AM 08/01/2022

# Simple echo three days from now
echo "echo hello" | at now + 3 days

Viewing and managing the job queue

List pending jobs with atq (or at -l):

atq
# Sample output
10 Thu Jul 29 12:19:00 2021 a tux
9  Tue Jul 27 03:30:00 2021 a tux
7  Tue Jul 27 00:00:00 2021 a tux

Remove a job by its ID using atrm (or at -d):

atrm 7
atq   # verify removal

Only the root user can inspect the raw spool files stored under /var/spool/at/. Use sudo cat or similar commands to view the actual script content.

Summary

The at command provides a simple way to schedule one‑time tasks without the recurring nature of cron. It supports natural language time specifications, interactive or pipeline‑based job definition, and basic queue management, making it suitable for ad‑hoc automation on any Linux system.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

task schedulingLinuxSystem Administrationat commandcron alternative
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.