Lesson 42: at Command
In this lesson, you'll learn how to use the at command to schedule a command to run once at a given time in Linux.
The at command is a Linux/Unix command-line utility utilized for scheduling a command to run once at a given time without editing a configuration file.
It is a useful job scheduler for automating tasks that need to occur at a later point without manual intervention.
Note: It is an alternative to the cron job scheduler.
Install and Enable the at Service
The only requirement consists of installing this utility and starting and enabling its execution:
# yum install at # CentOS based systems
$ sudo apt-get install at # Debian and derivatives
Next, start and enable the at service at boot time by executing the following commands:
# On SystemD
# systemctl start atd
# systemctl enable atd
# On SysVinit
# service atd start
# chkconfig --level 35 atd on
at Command Syntax
$ at [OPTIONS] TIME
at Command Options
| Option | Description |
|---|---|
-m |
Send an email to the user when the job is done (requires Postfix or equivalent) |
-l |
List all pending jobs (same as atq) |
-d JOB_ID |
Delete a pending job (same as atrm) |
-f FILE |
Read commands from a file instead of stdin |
-v |
Show the time the job will be executed |
now |
Schedule the job to run immediately |
noon |
Schedule the job to run at 12:00 |
midnight |
Schedule the job to run at 00:00 |