Skip to content

How to schedule one-time jobs in Linux with at

Time management is a complex art. Fortunately, with the help of technology, you can automate and delegate routine tasks to your computer. Unlike humans, PCs are very good at performing repetitive tasks at precisely set times.

On Linux, you can run repetitive tasks with tools like cron. In addition, you can also schedule and run one-time tasks with the at command.

Installation on Linux

The at command is not part of the standard Linux utilities on most distributions. Luckily, you can easily install it using your package manager, no matter what distribution you’re using.

On Debian based systems such as Ubuntu, MX Linux and Pop!_OS you can install by running:

sudo apt install at

If you are using an RPM based distribution like RHEL, Fedora or Rocky Linux, use DNF to install the package:

sudo dnf install at

On Arch-based Linux distributions such as Manjaro, run:

sudo pacman -S at

Starting the atd Task Scheduler Service

Before using the at command, ensure that the atd scheduling daemon is running. This is what the at command uses to execute scheduled jobs.

sudo systemctl status atd

001 5 - How to schedule one-time jobs in Linux with at001 5 - How to schedule one-time jobs in Linux with at

If the atd service is not running, you can start it using:

sudo systemctl start atd

Linux task scheduling with at

Here’s how you can schedule a one-time job to run at a specific point in time in the future using at:

command | at time_stamp

For example, we can schedule a task to list the contents of your current directory with the ls command and write the output to a file after one minute.

First go to the user’s home folder using the cd command:

cd ~

Then run the following command to schedule the task:

ls > list_items.txt | at now + 1 minutes

002 3 - How to schedule one-time jobs in Linux with at002 3 - How to schedule one-time jobs in Linux with at

The output will indicate that your task is scheduled. After the time has elapsed, you can list the contents of your directory and a new text file should appear with the contents of the directory.

If you want to run the command tomorrow at noon, run:

ls > list_items.txt | at noon tomorrow

To specify a more precise time and date, use the MMDDHHMM YYYY date format. For example, to execute the previous command at 13:00. On December 25, 2023, you can run the command:

ls > list_items.txt | at 12251300 2023

The at command has much more advanced features that allow you to run certain commands at a precise time. Take a look at its man pages for more command options:

man at

Linux scheduling scripts using at

In addition to running individual commands, you can also use the at command to schedule scripts to run at specified times.

Let’s say you have a script named located in your home folder. The script simply outputs the hard drive usage to a text file. Here is the scenario:

df -h > disk_usage.txt

To execute this script in thirty minutes, you can simply run the following command:

at now + 30 minutes -f ~/

Make sure your script is executable by setting it to the appropriate mode. To do this, you can use the chmod command:

sudo chmod +x

Managing Pending Tasks in Linux

You can view pending tasks using the following command:


003 1 - How to schedule one-time jobs in Linux with at003 1 - How to schedule one-time jobs in Linux with at

To remove a pending task, use the following command format:

atrm task_number

For example, to delete task number 12, use:

atrm 12

Automate repetitive tasks in Linux with at

The at command is a powerful and versatile tool for performing one-time tasks on your Linux PC. Besides at, you can use crontab to automate all kinds of tasks, from the simple to the complex.

2573800cookie-checkHow to schedule one-time jobs on Linux with atno

Publication author

offline 2 weeks


AEdFTp7yONh1pyC14k08EHSejujrCNwEKzHR2o 3E vHww=s96 c?sz=50 - How to schedule one-time jobs in Linux with at

Comments: 6Publications: 1196Registration: 29-04-2020


#schedule #onetime #jobs #Linux

❤ XOXO ❤

Leave a Reply

Your email address will not be published. Required fields are marked *