Difference between revisions of "CentOS 8.x Basics of at for running command at specific time"
(Created page with "<yambe:breadcrumb self="Basics of at for running command at specific time">CentOS 8.x atd or at|8.x atd or at</yambe:breadcrumb> =CentOS 8.x Basics of at for running command a...") |
m |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Main Page|Home]] > [[CentOS]] > [[CentOS 8.x]] > [[CentOS 8.x System Administration|System Administration]] > [[CentOS 8.x atd or at|atd or at]] > [[CentOS 8.x Basics of at for running command at specific time|Basics of at for running command at specific time]] | |||
We can use at, atq, atd etc. to run a specified job at a given time. There is also command batch which allows executing command when system load average is low (Default <0.8). This is different then cron which is used to run commands repeatedly after desired interval. | We can use at, atq, atd etc. to run a specified job at a given time. There is also command batch which allows executing command when system load average is low (Default <0.8). This is different then cron which is used to run commands repeatedly after desired interval. | ||
Line 38: | Line 37: | ||
* now + count time-units, where time-units can be minutes, hours, days, or weeks | * now + count time-units, where time-units can be minutes, hours, days, or weeks | ||
* 1am tomorrow | * 1am tomorrow | ||
The output of the job is emailed to user. So if /etc/aliases is set correctly and outgoing emails are working (postfix configure properly), then the output would be received via email. Other option is to redirect output to a file. | |||
Line 57: | Line 59: | ||
[[Main Page|Home]] > [[CentOS]] > [[CentOS 8.x]] > [[CentOS 8.x System Administration|System Administration]] > [[CentOS 8.x atd or at|atd or at]] > [[CentOS 8.x Basics of at for running command at specific time|Basics of at for running command at specific time]] |
Latest revision as of 03:38, 19 April 2022
Home > CentOS > CentOS 8.x > System Administration > atd or at > Basics of at for running command at specific time
We can use at, atq, atd etc. to run a specified job at a given time. There is also command batch which allows executing command when system load average is low (Default <0.8). This is different then cron which is used to run commands repeatedly after desired interval.
Ensure that atd is running
atd daemon or service is used to run jobs at specified time. To validate that it is running use:
systemctl status atd
Submit job to be executed at given time
We can submit job to be executed at given time using 'at' using following syntax
at -t <time> #After this type the commands one at a time on "at>" prompt #Use Ctrl+D to stop typing and complete submitting jobs
By default it goes to queue named 'a'. Here format of time is [[CC]YY]MMDDhhmm[.ss]
For example
[root@backup rsnapshot_backups]# at -t 11040840 at> /usr/bin/rsnapshot du at> <EOT> job 2 at Wed Nov 4 08:40:00 2020 [root@backup rsnapshot_backups]#
Here, giving full path /usr/bin/rsnapshot is not required. As such at will take current environment and use it while running the specified job.
There is more advanced option of using 'at -q <queue> timespec' where timespec can be
- 4pm + 3 days
- now + count time-units, where time-units can be minutes, hours, days, or weeks
- 1am tomorrow
The output of the job is emailed to user. So if /etc/aliases is set correctly and outgoing emails are working (postfix configure properly), then the output would be received via email. Other option is to redirect output to a file.
See the job queues
We can see the job queues and when they will be executing using:
atq
See job details
As such job details are not visible using at commands. But we can go to folder '/var/spool/queue' and search for job file with name '<queue-letter>000<job-no>'. For example to list job 2 of queue a we can use:
cat /var/spool/at/a00002019808fe
For Determining hexadecimal string '019808fe', first do 'ls /var/spool/at/' and then use the cat command.
Home > CentOS > CentOS 8.x > System Administration > atd or at > Basics of at for running command at specific time