Table of Contents
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.
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:
Or if your distribution is Fedore or CentOS, then you can use the below commands to install at command:
If you would like to list the jobs that are pending on the system, you can use “at -l” or “atq” commands.
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.
After writing the time with at commands, you can press enter. Then a new line will be appeared like below:
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.
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.
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.
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.
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 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.