Home > Package & System Management > at

at Command Guide: Scheduling One-Time Tasks

The `at` command is used to schedule a command to be executed only once at a specific time. Unlike `crontab`, which is used for recurring tasks, `at` is very useful for scheduling one-time jobs. It is suitable for tasks that only need to run once at a specific point, such as backups or system shutdowns.

at Command Overview

`at` creates a job that executes only once at a user-specified time. The job is queued along with the user's shell environment and runs in the background at the designated time. After entering the command, you can press Ctrl+D to terminate and schedule the job.

Advantages of using at

  • Allows intuitive time specification without complex time settings.
  • More convenient than `crontab` for scheduling tasks that simply run once.
  • Allows entering multiple lines of commands to be executed.

Key Options

Learn various ways to schedule and manage tasks using the `at` command.

1. Basic Usage and Job Scheduling

2. Job Management

Generated command:

Try combining the commands.

Description:

`at` Executes the command.

Combine the above options to virtually execute commands with AI.

Frequently Used Examples

Learn how to use the command through real-world scenarios utilizing `at`.

Shutdown system at a specific time

at 10:30 PM
> sudo shutdown -h now
> (Ctrl+D)

Schedules the system to shut down at 10:30 PM.

Display a notification message after 1 hour

at now + 1 hour
> echo "It's lunchtime!"
> (Ctrl+D)

Displays 'It's lunchtime!' message in the terminal 1 hour from the current time.

Execute script at 8 AM tomorrow

at 8:00 AM tomorrow
> /home/user/scripts/backup.sh
> (Ctrl+D)

Executes the `backup.sh` script at 8 AM tomorrow. (It's safer to specify the script path as an absolute path.)

Check scheduled job list

at -l

Checks all `at` jobs scheduled for the current user account.

Delete a specific scheduled job

at -r 1

Deletes the job using the job number (e.g., `1`) confirmed with the `at -l` command.

at Installation (if needed)

`at` is pre-installed on most Linux distributions. However, if it's not installed, you need to install the `atd` (at daemon) package using the commands below.

Debian/Ubuntu

sudo apt update
sudo apt install at

How to install atd on Ubuntu or Debian-based systems.

CentOS/RHEL/Fedora

sudo yum install at
sudo systemctl enable atd
sudo systemctl start atd

How to install atd on CentOS, RHEL, or Fedora-based systems.


Related commands

These are commands that are functionally similar or are commonly used together.


Same category commands