Hello, everyone In this Article we are going to learn how we can do Job scheduling using at command in Linux n a very simple and easy step-by-step approach.
Job Scheduling in Linux
With the job scheduling, we can schedule the tasks that we need to perform daily on our server for example we need to take backup in the server / We need to monitor the services in the server we need to run scripts daily in our server.
Instead of hiring the system admin, we can do the job scheduling the benefit of this is that we can schedule the tasks automatically that is run daily on the server
at – The at command is used to schedule the task in Linux. This is best for one time scheduling the task .
1 How to check the package for at command
To check whether we have at command package or not we can run rpm command with ( -qa )option
# rpm -qa at
2 How to check the status for at command
The atd is the demon of the at the command we need to check whether this is enabled or not.
# systemctl status atd
We can see that atd is dead we need to enable atd demon
3 How to start the atd demon–
With the help of systemctl command with start option atd demon name, we can start the atd demon and now it is showing that atd is enabled.
# systemctl start atd
4 How to check current time and date
With the help of date command we can see the current time and date in our system
# date
5 How to schedule a job using at command
To schedule the job then just write at the command and the date-time then it will ask for the command that we need to execute type that command and after typing the command press cntrl+d keys to save the task.
# at 10:15 AM Nov 16 2020 Nov 16 2020
6 How to check the task that we scheduled
With the help of atq command we can see what task is added to the schedule.
# atq
7 How to schedule a task afternoon
To schedule the job in the afternoon on 16 Nov 2020 then we can use the noon option in at the command with the date
# at noon Nov 16 2020
8 How to schedule a job in next day noon
To schedule the job at tomorrow afternoon at then we can use noon and tomorrow option in the at command.
# at noon tommorow
9 How to schedule a task for the next day
To schedule the job at next Monday at then we can use the day name with the next option in at command.
# at next monday
10 How to schedule the job after 10 minutes
To schedule the job after 10 minutes from the current time at then we can use the now + 10 minutes option in at the command.
# at now +10 minutes
11 How to schedule the job after 10 hours
To schedule the job after 10 hours from the current time at then we can use the now + 10 hour option in at the command.
# at now +10 hour
12 How to schedule the job after 2 days
To schedule the job after 2 days from the current time at then we can use now +2 day option in at command.
# at now +2 day
13 How to schedule the job after 3 weeks
To schedule the job after 3 weeks from the current time at then we can use now +3 weeks option in at command.
# at now +3 weeks
14 How to schedule the job after 5 years
To schedule the job after 5 years from the current time at then we can use the now +5 years option in at command.
# at now + 5 years
Now when we execute atq command then we can see the details of the commands that is scheduled ,
15 How to remove specific job
To remove the 5 number job then we can use atrm command with the job number we want to delete
Conclusion
If you want to learn Linux in the most simple language then please click on this link.
If you want to check manual for at command then click on this link
This is the complete knowledge of how we can schedule the job using at in the Linux kernel if you have any doubts please feel free to comment below. Please don’t forget to join our email subscription to get the latest updates on DevOps Articles.