linux定时任务2-at命令

定时执行命令:

[root@rheltest1 ~]# at now + 1 minute   //一分钟后执行下面的任务
at> date >> /tmp/test_date.log     //将当前时间写入到/tmp/test_date.log文件,ctl+d 结束
at> <EOT>
job 3 at 2016-04-12 22:32
[root@rheltest1 ~]# cat /tmp/test_date.log 
Tue Apr 12 22:32:00 CST 2016
[root@rheltest1 ~]# 

 定时执行脚本:

[root@rheltest1 ~]# at now + 1 minute
at> /root/test.sh
at> <EOT>
job 5 at 2016-04-12 22:40

 at命令的常见用法:

at 2pm + 2 days /root/test.sh      //2天后,下午2点执行test.sh脚本

at 10am + 2 weeks /root/test.sh   //2个星期后,早上10点执行test.sh脚本

at 12am tomorrow /root/test.sh    //明天早上12点执行test.sh脚本

at 00:00 04/15/2016    /root/test.sh  //2016年4月15日零点零分执行test.sh

at now + 5 hours /root/test.sh

at now + 20 minutes /root/test.sh

at -l 查看当前任务

at -d 4 删除at任务4

at -v 显示任务预设的运行时间

at -c 显示所有任务

原文地址:https://www.cnblogs.com/rusking/p/5384901.html