一次性计划任务at

2019-02-16  本文已影响0人  慕容晗曦

1、装包

[root@localhost ~]# yum -y install at

2、启动

[root@localhost ~]# systemctl start atd.service 

3、设置开机自启动

[root@localhost ~]# systemctl enable atd

4、设置计划任务(ctrl+d退出)
1)命令行

[root@localhost ~]# at now +5min
at> mkdir a
at> <EOT>
job 9 at Sat Feb 16 16:21:00 2019

2)文件写入,重定向

[root@localhost ~]# vim at.jobs
mkdir d
[root@localhost ~]# at now +1min < at.jobs
job 12 at Sat Feb 16 16:36:00 2019

5、查看计划任务

[root@localhost ~]# atq
9   Sat Feb 16 16:21:00 2019 a root

6、删除计划任务
1)直接删除

[root@localhost ~]# atrm 9

2)删除产生的文件

[root@localhost ~]# rm -rf /var/spool/at/文件

7、sudo提权
1)创建用户jack

[root@localhost ~]# useradd jack -G wheel

2)更改配置文件,sudo不需要密码

[root@localhost ~]# visudo 
## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL
## Same thing without a password
%wheel  ALL=(ALL)       NOPASSWD: ALL
[root@localhost ~]# su - jack
[jack@localhost ~]$ sudo useradd yy
[jack@localhost ~]$ vim jack.at
[jack@localhost ~]$ at now +1min<jack.at
job 13 at Sat Feb 16 16:47:00 2019
[jack@localhost ~]$ atq
13  Sat Feb 16 16:47:00 2019 a jack
[jack@localhost ~]$ atq
[jack@localhost ~]$ ls
a  b  jack.at
上一篇下一篇

猜你喜欢

热点阅读