美文网首页
一次性计划任务at

一次性计划任务at

作者: 慕容晗曦 | 来源:发表于2019-02-16 17:28 被阅读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
    

    相关文章

      网友评论

          本文标题:一次性计划任务at

          本文链接:https://www.haomeiwen.com/subject/ytrieqtx.html