You’ve probably used cron to schedule tasks and then realized the job only needs to run once.

A common example is giving a vendor temporary SSH access to a production server for troubleshooting.

You might open the firewall for their IP address and plan to remove the rule a few hours later.

The problem is that it’s easy to forget.

Production issues happen, priorities change, and before you know it, that temporary firewall rule is still sitting there long after it should have been removed.

This is where the at command comes in, which lets you schedule a one-time task to run at a specific time in the future, making it perfect for temporary changes that need to be automatically reversed later.

While most Linux administrators know about cron, many overlook at because cron gets most of the attention.

In this guide, we’ll explain what at is, how to schedule a one-off task, and how to manage queued at jobs in Linux.

The at command lets you schedule a command or script to run once at a specific time in the future.

You tell it when to run, provide the command, and Linux takes care of the rest.

Behind the scenes, at places the job in a queue, and a background service called atd checks that queue and runs the job when the scheduled time arrives.

This is what makes at different from cron.

cron is designed for recurring tasks, such as running a backup every night or generating a report every Monday and at is designed for one-time tasks that only need to happen once.

For example, you might use at to:

Think of it this way:

A good rule of thumb is that if you find yourself creating a cron job and then deleting it immediately after it runs, that task probably should have been scheduled with at in the first place.

On many Linux distributions, the at package is not installed by default, so you’ll need to install it first.

This installs the at command along with related utilities such as atq and atrm.

It also installs the atd service, which is responsible for running scheduled jobs at the correct time.

After installation, make sure the service is running and configured to start automatically after a reboot:

Output:

If you see that, the service is working correctly and ready to process scheduled jobs.

If atd is stopped or not running, any jobs you schedule with at will remain in the queue and never execute, which is one of the most common reasons new users think the at command isn’t working, so it’s always worth checking the service status first when troubleshooting.

Let’s go back to the example of giving a vendor temporary SSH access to a server, where you already opened the firewall to their IP.

On Ubuntu/Debian (ufw):

On RHEL/Rocky Linux (firewalld):

Rather than relying on yourself to remember to remove that rule later, you can schedule the removal right away using at.

For example, to remove the firewall rule at 10:00 PM:

You’ll be dropped into an interactive prompt where you can enter the command you want to run:

On Ubuntu/Debian:

On RHEL/Rocky Linux:

After pressing Ctrl+D, at saves the job and displays a job number.

In this example, job 3 has been scheduled to run at 10:00 PM.

One useful feature is that if the specified time has already passed today, at automatically schedules the job for the same time tomorrow.

If you already know the command you want to run, you can skip the interactive prompt and send the command directly to at.

Ubuntu/Debian:

RHEL/Rocky Linux:

The firewalld example contains escaped double quotes (“).

These backslashes prevent the shell from ending the quoted string too early and ensure the entire command is passed correctly to at.

Here’s what happens in the one-line version:

This approach is especially useful in scripts, automation tasks, or whenever you want to schedule a job quickly without entering the interactive prompt.

One of the most useful features of the at command is that it understands human-friendly time expressions.

Instead of calculating an exact time, you can simply tell Linux when you want the job to run relative to the current time.

For example, if a vendor only needs SSH access for the next two hours, you can schedule the firewall rule to be removed automatically after that period.

Output:

The at command understands several natural time expressions:

After scheduling one or more jobs with at, it’s a good idea to verify that they’re actually in the queue and waiting to run.

The atq command shows all pending jobs for the current user.

Output:

Each line represents a scheduled job.

Let’s break down the first entry:

The atq command is useful whenever you want to confirm that a task has been scheduled correctly.

For example, after creating a job to remove a temporary firewall rule, you can run:

and verify that the cleanup job is waiting in the queue before giving a vendor access to your server.

If atq returns no output, there are currently no pending jobs scheduled for your user account.

If a job is sitting in the queue and you’ve changed your mind, maybe the vendor finished early and you want the firewall closed right now instead of waiting, atrm cancels it before it runs.

Replace job-number with the number you saw in the atq output, that’s the angle bracket convention we’ll use anywhere in this guide for a value you need to fill in yourself.

There’s no output if it worked.

Run atq again right after and that job number should be gone from the list.

Just remember you still need to close the rule manually if you cancel the job, atrm only removes the scheduled task, not the firewall change itself.

The at command is one of those Linux tools that’s easy to overlook until you need it.

Whenever you have a task that should run once at a specific time, it’s usually a better choice than creating a temporary cron job.

Have you been using cron for jobs that only needed to run once? Drop a comment with what you’re scheduling and I’ll tell you whether at is the better fit.

5 Ways to Check Remote Port Connectivity in Linux

How to Resize ext4 Partitions and Filesystems in Linux

20 Must-Know Linux Commands for System Administrators

How to Stop Linux Processes from Using Excessive CPU and RAM

Create a Chat Server in Linux and 5 Other Terminal Tricks

witr: A Tool That Explains Why a Linux Process Is Running

How to add date along with time.

Hi,
Very useful article

remove extra ‘d ‘ from atdd

# chkconfig –level 35 atdd on

@Jalal,

Thanks for finding it useful, and corrected in the writeup..

Very useful, thank you!

Good article, Gabriel!

Just my 5 cents to it.

“at” can be used to start something on background, like nohup staff, but more short:
$ echo “rsync remote_resource local_resource” | at now
or
$ at -f /path/to/my/script -m now
just notice “-f script” option – it’s very convenient to run more complex staff

“at” can be used instead of cron to run something repeatedly after the first execution ends.

This can eliminate cronjobs, scheduled to run each minute with various locks to avoid to run several commands simultaneously.

One can add at the end of its script:
—— bash code snippet —–
# script payload here
this_script_name=$(basename $0)
this_script_path=$(readlink –canonicalize $(dirname $0))
at -f $this_script_path/$this_script_name now
—— bash code snippet —–
this will start the script again when it’s finished.

Another interesting application that’s unable to implement with cron is periodically execution with random intervals.

Mostly the same as abouve, but just add random delay:
—— bash code snippet —–
# script payload here
this_script_name=$(basename $0)
this_script_path=$(readlink –canonicalize $(dirname $0))
MIN_DELAY=15
RANDOM_BIAS=20
delay=$(( ($RANDOM % $RANDOM_BIAS) + $MIN_DELAY ))
at -f $this_script_path/$this_script_name now + $delay min
—— bash code snippet —–

That’s all 🙂

Web VMStat: A Real Time System Statistics (Memory, CPU, Processess, etc) Monitoring Tool for Linux

A Shell Script to Monitor Network, Diske, Uptime, Load, and RAM in Linux

Collectl: An Advanced All-in-One Performance Monitoring Tool for Linux

ngxtop – Monitor Nginx Log Files in Real Time in Linux

Install Glances, InfluxDB and Grafana to Monitor CentOS 7

Iotop – Monitor Linux Disk I/O Activity and Usage Per-Process Basis

Understanding APT, APT-Cache and Their Frequently Used Commands

How to Find a Process Name Using PID Number in Linux

Kurly – An Alternative to Most Widely Used Curl Program

8 Linux Commands to Diagnose Hard Drive Issues in Linux

2 Ways to Create an ISO from a Bootable USB in Linux

8 Useful ‘Debian Goodies Utilities’ for Package Management

6 Best Whiteboard Applications for Your Linux Systems

Top 5 Linux Programs for Students in 2025

5 CLI Tools for Downloading Files and Browsing Internet in Terminal

12 Open-Source WYSIWYG Editors Worth Using in 2026

25 Outstanding Backup Utilities for Linux Systems in 2024

11 Best GitHub Alternatives to Host Open Source Projects

**📚 Original Source:**
[at Command: Schedule One-Time Linux Tasks Without Cron](https://www.tecmint.com/at-command-linux/)

About The Author

By admin