atrm Command in Linux



atrm is a command used in Linux systems to remove or delete at scheduled jobs from the queue. The at is basically a command-line utility that you can use to create and schedule your jobs or tasks. When you use the at command to schedule tasks, they are added to the queue for later execution.

If you have created a few jobs by mistake and you don’t need them, you can remove them through the atrm command. Removing the job will prevent it from being executed at their scheduled time.

Table of Contents

Syntax for atrm Command in Linux

The syntax to use the atrm command on Linux is pretty simple, which is provided below −

atrm [job_number-to-delete]

Here, keep the atrm keyword the same, as it will invoke the atrm command. However, replace the [job_number-to-delete] keyword with the job number (in numerical, such as 1, 2) you want to delete from your Linux system.

It is also important to keep in mind that only the superuser has the authority to delete any job, even if it belongs to another user.

Options Used with the atrm Command

There are only two options you can use with the atrm command, that is -V and [job_number-to-delete].

If you use the -V option with the atrm command, you will be able to see the at command-line utility version on your Linux system −

atrm -V
atrm Command Linux 1

While, the other option is the [job_number-to-delete] that you can replace with a specific job number to delete the at scheduled job from your system.

Examples of atrm Command in Linux

You can use the atrm command on your Linux system to remove −

  • Removing a Single Job
  • Removing Multiple Jobs

However, before removing the at scheduled jobs from the system, first, find out the list of scheduled jobs and their specific job ID. You can find the list of scheduled jobs and their IDs using the atq command provided below −

atq
atrm Command Linux 2

Once you find your at scheduled jobs’ ID, it's now time to remove the jobs from the system.

Removing a Single Job Through atrm Command

If you want to remove a single at scheduled job from your system, you can use the atrm command followed by the job number that you want to delete from the at jobs queue.

As an example, we are removing a job scheduled on Thu Jun 6 with job number 28 from the system using the following command −

atrm 28
atrm Command Linux 3

Once the job is removed, use the atq command again to verify the removal of your desired job from the list.

atrm Command Linux 4

The above output confirms that job number 28 is successfully removed from the at scheduled jobs queue.

Removing Multiple Jobs Through atrm Command

Besides removing a single job, you can also use the atrm command to remove multiple jobs simultaneously from the at scheduled jobs queue. For that purpose, simply use the atrm command followed by the jobs numbers you want to remove separated by a single space.

For example, to remove job numbers 18 and 29, use the following command −

atrm 18 29
atrm Command Linux 5

Note − Don’t forget to run the atq command for verification of job removal from the at scheduled jobs queue.

Alternatives of atrm Command in Linux

Besides using the atrm command on Linux to delete at scheduled jobs, you can also use the at command with -r flag to perform a similar operation.

For example, if you want to delete a single at scheduled jobs let’s say job number 30 from the queue, use the following command −

at -r 30
atrm Command Linux 6

To remove or delete multiple at jobs from a queue, let’s say jobs number 31 and 25, you can run the following command −

at -r 31 25
atrm Command Linux 7

In this way, you can remove a job or multiple jobs from your at jobs queue list on the Linux system.

Conclusion

atrm commands is a powerful command that directly removes your at scheduled jobs from your Linux system. The syntax of the command is simple and takes only the job number as input. The job number of the at scheduled jobs can be found easily through the atq command.

After finding the job number, you can use the atrm command to remove a single or multiple at scheduled jobs from the jobs queue list. Further, the at command with the -r option can also be used to remove a single or multiple at scheduled jobs, similar to the atrm command.

Advertisements