How to Use atrm Command in Linux

Most users are aware of automation’s capability of optimizing workflows. Linux scripting is one of the most popular options to do automation. But deleting unnecessary queued tasks is also important to improve the workflow. This applies to queues that are accidentally duplicated or are not configured properly. In these situations, the atrm command in Linux is very handy.

What is atrm Command in Linux?

The atrm command is a part of quadruple utility tools for scheduling automated jobs. Alongside atrm are the commands at, atq, and batch, which are all used to set up complicated automated tasks but need to be executed within a schedule.

These four commands are amazing in executing a one-time elaborate set of commands. For example, if you need to run multiple scripts to organize a directory, the at command is a great option.

However, if you need to execute a repeating task (such as system updates), you might want to use the cron command instead. But if you want to get reminded that you have to attend your son’s soccer game next week, the at commands are preferred.

How to Install atrm Command?

To install the at command on Ubuntu and other Debian-based distros, you can use synaptic and find the respected package. Or for convenience, just use apt and download the at package which already contains atrm, at, atq, and batch. You can also use the yum package manager if you’re using a Red Hat distro.

$ sudo apt install at
$ sudo yum install at

Default atrm Syntax

Using the atrm command is very simple: execute the atrm command followed by the number corresponding to the task queued. If there is no existing task on the queue, the standard output will show a “Cannot find job ID” message.

$ atrm job_number

Due to its functions, the atrm command is very dependent on the at and atq commands. The user will need to actually input a task via at so atrm have something to process. On the other hand, the atq command is for finding and verifying the right job_number for a specific task.

Example Uses of atrm Command

Users can only delete jobs created from their accounts unless the user has elevated access. If that’s the case, the user can view and delete any tasks from any account. There are only two instances to use the atrm command in Linux: erasing single or multiple tasks.

1. Deleting Single Jobs

You can delete a single job by using the default syntax, executing atrm, and following it with the job number from your queue. Once you press Enter, the command will go through and erase a queued job. Unfortunately, there is no prompt to confirm if you’re sure about your final selection, so only press the “Enter” key when you’re fully sure about your choice.

using atrm command in Linux

Note: If you want to avoid accidentally deleting a task (especially if you’re a superuser), using the atq command before atrm is a good habit to develop.

2. Deleting Multiple Jobs

To erase two or more jobs in the queue, just add the numbers after the atrm command and separate them with space. Don’t forget to run atq and check the specific number to avoid deleting a task that you don’t want to delete.

deleting multiple tasks with atrm

As mentioned before, atrm is bundled with other command-line utilities. All are dependent on one another, specifically the at command which makes the actual task scheduling. We will take a bit for all the commands included in the bundle below.

The at Command

Unlike atrm and atq, the at command has two parts: date scheduling and task queuing. First, you need to specify the time to execute the task. This is done by using at followed by the time in 12-hour format.

Next, a warning will appear informing that all commands are executed at /bin/sh. After that, you need to add jobs either via the standard input or via files.

at command

Here are the relevant options available for the at command. Like other Linux commands, you can use the options below by running the command, following with the preferred option, and then with any applicable argument.

$ at option time

-m: automatically sends mail notifications after task completion

-f: reads input from a file (e.g. scripts)

-v: shows the time of job execution

Next, the user needs to specify the commands for this schedule via standard input or file. Once the steps are done, the standard output will return a summary of the schedule. Queued tasks will be executed even if you’re not logged in, as long as the system is running. All the task output will be sent to your mail option when using -m.

The atq command

Users don’t need to add any options or arguments to run the atq command. Once executed, it will show the list of all queued tasks with their corresponding job number, schedule, and the related user account.

atq command

The batch Command

Just like atq, the batch command doesn’t require options and other arguments to work. After the user executes the command, a secondary prompt will appear wherein you can queue in multiple tasks. batch is very similar to at, the only difference is that all tasks on the queue will be executed when the average system load is lower than 1.5.

batch command

You can check your server load with the top command. Since batch uses the load average, the system will prioritize other tasks until the load goes down. If you want an immediate result, you might want to use at instead.

And that’s all you need to know with the atrm command and other associated tools. Please check our How-To’s and Linux Commands sections for more guides. Check our newest guides to learn more about PIP or Apache installations.

If this guide helped you, please share it. ?

Leave a Reply
Related Posts