The at command is used to run a task once, at a specified time. It is not designed for repetitive or regularly scheduled tasks. The at command is very flexible. Users can specify a particular date and time, or cause the scheduled command to run after a given period of time. The command is typically used in an interactive manner, where the at command and time interval are specified, then a task is defined in an interactive prompt. This enables the user to enter a path to a script or a command to be run. Pressing Ctrl+D exits the interactive mode.
Syntax
The syntax of the at command is:
# at [options] {time}
at Command Options
Some of the at command options are described in the following table.
Options | Used To |
---|---|
-m | Send mail to the user when the job completes, |
-M | regardless of output. |
-f {file name} | Prevent mail from being sent to the user. |
-t {time} | Read a job from a file rather than standard input. |
-v | Run the job at the specified time value. Display the time the job will be executed. |
Time Specifications
The at command takes several possible arguments for specifying time. Examples include:
- noon to specify 12 P.M.
- teatime to specify 4 P.M.
- midnight to specify 12 A.M.
- now + 3 minutes to specify the time three minutes from now.
- now + 1 hour to specify the time one hour from now.
at Command Examples
1. Execute commands from standard input in 5 minutes (press `Ctrl + D` when done):
# at now + 5 minutes
2. Execute a command from standard input at 10:00 AM today:
# echo "./make_db_backup.sh" | at 1000
3. Execute commands from a given file next Tuesday:
# at -f path/to/file 9:30 PM Tue