The at
command in Linux is used to schedule a task to run at a specific time. This can be useful for automating tasks that need to be performed at a certain time or for running tasks during off-peak hours.
Overview
The at
command is used to schedule a task to run at a specific time. The syntax for the command is as follows:
at [-f filename] [-m] [-q queue] [-t time] [-v] [time]
The time
argument specifies when the task should be run. This argument can be specified in a variety of formats, including absolute times, relative times, and even natural language.
For example, to schedule a task to run at 2:30 PM on June 1st, you would use the following command:
at 2:30pm June 1
Once the at
command is executed, you will be prompted to enter the command that you want to run at the specified time. For example, if you wanted to schedule a backup script to run at 2:30 PM on June 1st, you would use the following commands:
at 2:30pm June 1
at> /path/to/backup/script.sh
at> <EOT>
The at
command will then schedule the task to run at the specified time. You can view a list of scheduled tasks by using the atq
command, and you can remove a scheduled task by using the atrm
command followed by the job number.
Options
The following table lists the available options for the at
command:
Option | Description |
---|---|
-f | Specifies a filename to read the command from |
-m | Sends an email to the user when the task is complete |
-q | Specifies the queue that the task should be added to |
-t | Specifies the time that the task should be run |
-v | Verbose output |
Troubleshooting Tips
- If a task does not run at the scheduled time, check the system logs for any error messages related to the
at
command. - If the
at
command is not available on your system, you may need to install theat
package using your system’s package manager.
Notes
- The
at
command requires theatd
daemon to be running on your system in order to function properly. - The
at
command is not available on all Linux distributions by default, so you may need to install it manually.