linux中at延时命令

at命令,实现延时任务的功能。


at 时间

at now+5min

at 16:00

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

>ctrl+d


at -l    查看任务编号

at -c 3  找到编号为3的任务

at -r 3  撤回编号为3的任务


at命令的黑白名单:

[root@node1 ~]# useradd westos    建立两个用户方便实验

[root@node1 ~]# useradd linux

[root@node1 ~]# at now+1min       超级用户可以执行at命令

at> <EOT>

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

[root@node1 ~]# su - westos    

[westos@node1 ~]$ at now+1min    切换到westos用户执行at命令可以使用at命令

at> <EOT>

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

[westos@node1 ~]$ logout

[root@node1 ~]# su - linux       切换到linux用户执行at命令可以使用at命令

[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  添加linux为黑名单


[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不可以执行at命令

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命令。

猜你喜欢

转载自blog.csdn.net/aaaaaab_/article/details/80145245