at delay command in linux

The at command implements the function of delaying tasks.


at time

at now+5min

at 16:00

>touch /mnt/file{1..10}

>ctrl+d


at -l to view the task number

at -c 3 finds task number 3

at -r 3 undo task number 3


Black and white list of at commands:

[root@node1 ~]# useradd westos Create two users for easy experimentation

[root@node1 ~]# useradd linux

[root@node1 ~]# at now+1min Super user can execute at command

at> <EOT>

job 1 at Sat Apr 14 16:50:00 2018

[root@node1 ~]# su - westos    

[westos@node1 ~]$ at now+1min switch to the westos user to execute the at command, you can use the at command

at> <EOT>

job 2 at Sat Apr 14 16:50:00 2018

[westos@node1 ~]$ logout

[root@node1 ~]# su - linux Switch to the linux user to execute the at command, you can use the at command

[linux@node1 ~]$ at now+1min

at> <EOT>

job 3 at Sat Apr 14 16:51:00 2018

[linux@node1 ~]$ logoutvim

[root@node1 ~]# vim /etc/at.deny add linux to the blacklist


[root@node1 ~]# at now+1min

at> <EOT>

job 4 at Sat Apr 14 16:52:00 2018

[root@node1 ~]# su - linux     

Last login: Sat Apr 14 16:49:56 CST 2018 on pts/0

[linux@node1 ~]$ at now+1min Linux cannot execute at command

You do not have permission to use at.

[linux@node1 ~]$ logout

[root@node1 ~]# su - westos

Last login: Sat Apr 14 16:49:31 CST 2018 on pts/0

[westos@node1 ~]$ at now+1min

at> <EOT>

job 5 at Sat Apr 14 16:52:00 2018

[westos@node1 ~]$ logout


[root@node1 ~]# vim /etc/at.deny      将黑名单用户删除掉

[root@node1 ~]# ll /etc/at.allow      添加linux为白名单


ls: cannot access /etc/at.allow: No such file or directory

[root@node1 ~]# vim /etc/at.allow

[root@node1 ~]# at now+1min

at> <EOT>

job 6 at Sat Apr 14 16:53:00 2018

[root@node1 ~]# su - westos

Last login: Sat Apr 14 16:51:34 CST 2018 on pts/0

[westos@node1 ~]$ at now+1min       westos不再白名单内不可以执行at命令

You do not have permission to use at.

[westos@node1 ~]$ logout

[root@node1 ~]# su - linux

Last login: Sat Apr 14 16:51:25 CST 2018 on pts/0

[linux@node1 ~]$ at now+1min

at> <EOT>

job 7 at Sat Apr 14 16:53:00 2018

[linux@node1 ~]$ logout

[root@node1 ~]# vim /etc/at.allow   将白名单用户删除掉


***白名单出现时黑名单失效,所有人不可以登录,只有root用户以及白名单里面的用户可以执行at命令。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325654788&siteId=291194637