The at command is a standard job scheduling utility used in Unix-like operating systems and Microsoft Windows to execute commands or scripts at a specified time in the future. Unlike the cron utility, which is designed for recurring tasks, at is primarily used for one-time task execution.
Functionality and Operation
On Unix-like systems, the at command reads instructions from standard input or a specified file and queues them for execution at a later time. The execution environment, including the current working directory and environment variables (excluding TERM, DISPLAY, and others), is typically preserved for the scheduled job.
The utility generally relies on a background service, or daemon, known as atd. This daemon periodically checks the job queue and executes tasks when their scheduled time arrives. Users can interact with the queue using related commands:
- atq: Lists the user's pending jobs.
- atrm: Removes specified jobs from the queue.
- batch: Executes commands only when system load levels drop below a certain threshold.
Syntax and Scheduling
The command supports various time formats, including absolute times (e.g., at 10:30 PM) and relative offsets (e.g., at now + 30 minutes). It also recognizes specific keywords such as midnight, noon, and teatime.
Access Control
Access to the at command is typically controlled through two configuration files:
- /etc/at.allow: If this file exists, only users listed within it are permitted to use the command.
- /etc/at.deny: If
at.allowdoes not exist, any user listed in this file is prohibited from using the command. If neither file exists, system configurations vary; in some environments, only the superuser is permitted to use the utility.
Windows Implementation
In Microsoft Windows, the at command was historically used to schedule tasks via the Schedule service. However, it has been deprecated in later versions of Windows (starting with Windows 8 and Windows Server 2012) in favor of the schtasks command-line tool and the Task Scheduler graphical interface. Commands scheduled with at in Windows run under the SYSTEM account by default.