at Command: Tutorial & Examples

Execute a command at a specified time

The at command is a Linux utility that allows you to schedule a command or script to run at a specific time in the future. It is useful for scheduling tasks that need to be performed on a one-time or recurring basis, such as backups, system maintenance, or email notifications.

To use at, you must first specify a time and date for the task to run. You can do this by providing a numerical value for the time, such as 14:30 for 2:30 PM, or by using keywords such as midnight, noon, or teatime (4 PM). You can also specify a relative time, such as now + 1 hour or next Monday.

Once you have specified the time, you can enter the command or script that you want to run. You can enter the command directly on the command line, or you can specify a script file by using the -f option. For example:

at 14:30
at> /path/to/script.sh

or

at -f /path/to/script.sh 14:30

When you are finished entering the command or script, press CTRL+D to submit it to the at daemon. The at daemon will execute the command or script at the specified time.

You can view a list of tasks scheduled to run with at by running the atq command. You can cancel a scheduled task by running atrm followed by the task's ID, which can be found by running atq.

Note that the at command is not enabled by default on all Linux distributions. You may need to install the at package and configure the atd daemon to start automatically at boot before you can use it.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA