linux单次任务at

任务计划:
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值