How to Schedule One-Time Jobs on Linux Using at

Time management is a difficult art to master. Fortunately, with the help of technology, you can automate and delegate mundane tasks to your computer. Unlike humans, PCs are very good at running repetitive tasks at a precise set time.

On Linux, you could run repetitive tasks using tools such as cron. In addition, you can also schedule and run one-time tasks using theatcommand.

4

Installing at on Linux

The at command is not part of the standard Linux utilities on most distros. Luckily, you can easily install it using your package manager regardless of the distro you’re using.

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

linux pc displaying time in large font

If you are using an RPM-based distro such as RHEL, Fedora, or Rocky Linux,use DNF to install the package:

On Arch-based Linux distros like Manjaro, run:

checking the status of the atd time scheduler

Starting the atd Job Scheduler Service

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

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

scheduling a simple job with at

Scheduling Tasks on Linux With at

Here’s how you can schedule a one-time job to be executed at some given time in the future using at:

For example, we can schedule a task to list the contents of your current directoryusing the ls commandand write the output to a file a minute from now.

listing jobs with atq

First, change to your user home folderusing the cd command:

Then, execute the following command to schedule your task:

The output will state that your task has been scheduled. After the time has elapsed, you can list the contents of your directory and a new text file with the directory contents should be present.

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

For more specific times and dates, use the date formatMMDDHHMM YYYY. For example, to execute the preceding command at 1 p.m. on 25th December 2023, you can run the command:

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

Scheduling Scripts on Linux Using at

Apart from running individual commands, you’re able to also use the at command to schedule scripts to be executed at specified times.

Let’s assume that you have a script nameddisk_usage.sh, located in your home folder. The script simply prints out hard disk usage to a text file. Here’s the script:

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

check that that your script is executable by giving it the appropriate mode. To do that, you could use the chmod command:

Managing Pending at Tasks on Linux

You can view pending tasks using the following command:

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

For example, to delete task number 12, use:

Automate Repetitive Tasks on Linux With at

The at command is a powerful and versatile tool for executing or running one-time jobs on your Linux PC. Apart from at, you can use crontab to automate all sorts of tasks, ranging from simple to complex jobs.

Want to save time and automate key processes in Linux? Crontab is the answer.

Not Linux, not Windows. Something better.

These films will leave you questioning humanity, but also wanting more.

It’s not super flashy, but it can help to keep your computer up and running.

Sometimes the smallest cleaning habit makes the biggest mess.

These plugins will make you wonder why you used Photoshop in the first place.

Technology Explained

PC & Mobile