1.at Scheduled Tasks
at a scheduled task, the task is executed only once at a specified event.
1) execute a script in one day
[root@centos7 xx]# at 2020-3-25 at> /bin/aa.sh at> <EOT> job 2 at Wed Mar 25 15:31:00 2020
Our time here is only accurate to the day, the specific time to perform the task that point in time to submit the task (designated day). Such as this example, the point in time of task execution of 2020-3-25 15:31:00.
Note that submitting a scheduled task, use Ctrl + D .
2) specify a specific execution time
[root@centos7 xx]# at 10:00 2020-3-25 at> /bin/aa.sh at> <EOT> job 3 at Wed Mar 25 10:00:00 2020
Note that only the specific time to the minutes (not accurate to the second), a 24-hour time system is employed.
3) a period of time after execution
[root@centos7 xx]# at 4:00 + 1weeks at> /bin/aa.sh at> <EOT> job 4 at Mon Mar 30 04:00:00 2020
That's four in the morning a week later execution. Time units are: minutes, hours, days, weeks . If executed during this time after a certain period of time, you can use AT + 3days now .
4) Check the scheduled task already exists
[root@centos7 xx]# atq 2 Wed Mar 25 15:31:00 2020 a root 3 Wed Mar 25 10:00:00 2020 a root 4 Mon Mar 30 04:00:00 2020 a root 6 Thu Mar 26 15:38:00 2020 a root [root@centos7 xx]# at -l 2 Wed Mar 25 15:31:00 2020 a root 3 Wed Mar 25 10:00:00 2020 a root 4 Mon Mar 30 04:00:00 2020 a root 6 Thu Mar 26 15:38:00 2020 a root
5) How to view the contents at specific scheduled task execution
cd / var / spool / to
[root@centos7 at]# ls a0000201931e03 a0000301931cb8 a0000401933770 a00006019323aa spool
You can see that all the scheduled tasks corresponding to the document, the first five-digit number corresponding to the number of scheduled tasks. We can open the file:
[root@centos7 at]# cat a0000201931e03 #!/bin/sh # atrun uid=0 gid=0 ... ... ${SHELL:-/bin/sh} << 'marcinDELIMITER59a4f86f' /bin/aa.sh
In the end, we can see that our script is executed / bin / AA. SH .
6) Delete the scheduled task at
[root@centos7 at]# atrm 2 [root@centos7 at]# at -d 3
Use atrm or at -d plus the job number can be deleted.
Delete 1-6 tasks:
atrm { 1 .. 6 }
Permissions 7) the scheduled task
If we do not want a user has permission to do the scheduled tasks, you can edit /etc/at.deny :
leo
kale
The need to reject username written to a file, one per line user name.
===