任务计划:
at --一次性计划任务,在一个指定的时间执行一个指定任务,只能执行一次,且需要开启atd进程
#rpm -q at --确认at这个服务是否已经安装
at-3.1.8-82.fc6
举例
[root@localhost ~]# ps -aux | grep atd
root 1386 0.0 0.0 25956 968 ? Ss 14:12 0:00 /usr/sbin/atd -f
root 3849 0.0 0.0 112644 952 pts/0 R+ 14:44 0:00 grep --color=auto atd
[root@localhost ~]# at 17:20 tomorrow
at> date > /root/2018.log
at> <EOT>
job 1 at Sat Mar 3 17:20:00 2018
[root@localhost ~]#
在今日的 HH:MM 时刻进行,若该时刻已超过,则明天的 HH:MM 进行此任务。
crtl + d --结束
at 1212 ---当天12点12分执行
at> echo hello
at> <EOT>
at noon + 4 days ----4天后 的下午
at teatime tomorrow -----明天下午茶时间 16:00
##################
rpm -ql at
/etc/at.deny --拒绝用户
/etc/pam.d/atd --认证
/etc/rc.d/init.d/atd --at启动脚本
/usr/bin/at --命令
/usr/bin/atq --查看at的任务列表
/usr/bin/atrm --删除任务
# atq --通过命令来查看at的任务
[root@localhost ~]# atq
1 Sat Mar 3 17:20:00 2018 a root
++++++++++++++++++++++
用户控制
/etc/at.allow ----只允许允许的用户,其他人拒绝
/etc/at.deny ----只拒绝拒绝的用户,其他人允许
/etc/at.allow 如果这个文件存在,就不去考虑at.deny.而且他的作用:只允许文件里面出现的用户使用atd这个服务
# vim /etc/at.allow
test1
# rm -fr /etc/at.allow
/etc/at.deny 如果at.allow不存在的时候,才生效,作用:只拒绝里面的用户使用atd
atq 查看任务
atrm 任务编号 -------删除任务
实例一:三天后的下午5点执行/bin/ls
[root@rhel7 ~]# at 5pm+3 days
at> /bin/ls
at> <EOT>
job 7 at Wed Oct 18 17:00:00 2017
# atq --通过命令来查看at的任务
[root@rhel7 ~]# atq
5 Tue Aug 29 17:18:00 2017 a root
[root@rhel7 ~]# ls /var/spool/at/
a00005017e7c8e spool
linux单次任务at
最新推荐文章于 2024-09-04 17:54:42 发布