Linux Scheduling and Linux at Command

linux-at-command-ipcisco

Linux at Command

 

In Linux administration, sometimes we need to Schedule jobs. One of the ways to schedule jobs in Linux is using Linux at command. With at command, you can schedule a command that you allowed to execute and Linux system executes it once.

 

There are different options used with at command. Here, we will discuss, each of these options with different examples.

 

How to Install at Command?

 

If at command is installed in you Linux distribution or now. If it is not installed, you can install it like below in different distributions.

 

If your system is Ubuntu or Debian, you can use the below commands to install at command:

 

sudo apt update

 

sudo apt install at

 

Or if your distribution is Fedore or CentOS, then you can use the below commands to install  at command:

 

sudo yum install at

 

 


 

Listing Pending Jobs

 

If you would like to list the jobs that are pending on the system, you can use “at -l” or “atq” commands.

 

at -l

 

or

 

atq

 


 

Scheduling a Job With Exact Date

 

We can schedule any job in Linux with giving the exact date with at command. Below, we will do it at 6:00 am of twenty-five of July 2021.

 

at 6:00 072521

 


 

How to Enter Commands With Linux at Command?

 

After writing the time with at commands, you can press enter. Then a new line will be appeared like below:

 

at 6:00 072521
at>

 

Here, you can write the command that you would like to execute. In our example, this command will  be “tar” command with option “-xf”. The location of the file will be /home/xyz.tar.gz.

 

at> tar -xf /home/xyz.tar.gz

 


 

Scheduling a Job With Days

 

We can schedule a command on a specific day with at command. Below, you will find an example in which we will schedule a command at Friday after 50 minutes later than now.

 

at Friday +50 minutes

 

linux-at-command-example-1

 


 

Scheduling a Job After Any Days, Hours

 

We can schedule a command to execute after any mentioned days. Below, we will use Linux at command to schedule a command a at 5pm after 3 days from now.

 

at 5pm + 3 days

 

linux-scheduling-example

 

We can also use do this after any hours from now. Below, we will schedule a job that will execute after 2 hours from now.

 

at now +5 hours

 

linux-scheduling-ipcisco

 


 

Deleting a Job with Linux at command

 

We can delete the scheduled jobs in the system with “at -r” or “atrm” commands. For example, to remove job 5, we will use the below command:

 

at -r 5

 

or

 

atrm 5

 


 

Conclusion

 

At command in Linux is very important for job scheduling. If you would like to schedule any job in Linux, you will use this command often. With different examples, you can also increase these examples by yourself.

Back to: Kali Linux Course

Leave a Reply

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