Introduction
In Linux system administration, it is often necessary to run a command or script at a specific future time without keeping an open session. While cron manages recurring tasks, the at command is designed for one‑off jobs that run only once. This article explains what at is, how to install it, its syntax, and practical examples for scheduling tasks quickly and safely.
What the at command is
The at command belongs to the at package and allows you to specify an execution time for any command or sequence of commands. When invoked, at opens an interactive prompt where you write the command; finishing with Ctrl+D saves the job in the at queue and it runs at the indicated time. The atd daemon monitors the queue and launches processes when their time arrives.
Installation and verification
In most distributions at is already installed. If it is missing, install it with the package manager:
- On Debian/Ubuntu:
sudo apt-get update && sudo apt-get install at - On Fedora:
sudo dnf install at - On Arch Linux:
sudo pacman -S at
After installation, enable the daemon:
sudo systemctl enable --now atd
Check its status with systemctl status atd.
Basic syntax
The simplest way to use at is:
at HH:MM
After pressing Enter, the at> prompt opens where you write the command or commands you want to run. When finished, press Ctrl+D (or type EOF) to close the input and schedule the task.
You can also pipe input directly or provide it from a file:
echo 'command to run' | at HH:MM
Or:
at HH:MM < file.txt
Practical example
To display a reminder at 15:00:
at 15:00 > echo 'Meeting in 5 minutes' > Ctrl+D
The message will appear in the terminal at the indicated time.
Advanced date and time
The command accepts formats such as now + 30 minutes, at 22:00 tomorrow or at 10:00 2025-12-31. It also allows expressions like teatime (which equals 16:00).
Job management
List pending jobs with atq. Delete a job by its number using atrm number. Multiple numbers can be separated by spaces.
Advantages over cron
- No need to edit the system or user crontab.
- Allows specifying an exact time easily, even using natural language like
now + 45 minutes. - The process is automatically removed from the queue after execution, avoiding accumulation of obsolete entries.
- Useful in scripts that need to schedule a future action based on a condition detected at runtime.
Limitations and security considerations
- This post is also available in ESPAÑOL.