Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Schedule a One-Time Task with the at Command

Run a command or script once, at a time you choose. cron repeats tasks, at runs them one time.

VPS and Cloud Servers2 min read8 screenshots

What at does

The at command reads commands and runs them once at the time you set. If you need a task to repeat, use cron instead.

Install at

at is not installed on every system.

Debian and Ubuntu

sudo apt install at

Red Hat, CentOS and AlmaLinux

sudo yum install at

Make sure the service runs:

sudo systemctl enable --now atd

Syntax

at [option] time

Common options:

OptionMeaning
-q queueUse a job queue (the default is a)
-f fileRead the job from a file
-mSend an email when the job is done
-lList pending jobs
-dDelete a pending job
-vShow the time the job will run

Common time words: now, noon (12:00), midnight (00:00), teatime (16:00), today, tomorrow, AM, PM. You can also give a full date like 202612311800.

For the full manual, run man at.

The at manual page

Examples

Run a command in 3 minutes

echo "sudo reboot" | at now + 3 minutes
Scheduling a reboot

List the waiting jobs

at -l

You can also use atq. The list shows the job number.

The list of scheduled jobs

Delete a job

at -d 15

List the jobs again to confirm it is gone.

A job removed from the queue

Send an email when the job runs

cat sampleFile.txt | at -m midnight
A job with an email notice

Show what a job will run

at -c 16
The content of job 16

Run on the next Tuesday

at Tuesday +25 minutes
A job set for Tuesday

Save the output to a file

echo "df -h > /home/user/storageDetails.txt" | at now + 15 minutes
Disk report saved to a file

Quick recap

  • at runs a task once. cron repeats a task.
  • Use at -l to list jobs and at -d to remove one.
  • Add -m if you want an email when the job ends.