简单的php代码设置at定时任务
<?php
$fp = @popen('at now +1 minutes',"w");
$fp1 = @fputs($fp,"echo 'ok'>1.txt");
$fp2 = @fputs($fp1,"<EOT>");
@pclose($fp);
@pclose($fp1);
@pclose($fp2);
at在linux终端中的使用
列出当前待执行的任务,atq
取消待执行列表中的任务,使用atrm 任务编号:
at格式:at #执行的时间#at->#执行的任务脚本#at->#执行的任务脚本#at->在命令行输入at,然后指定执行的时间,在输入enter键换行,接下来输入要执行的任务,多任务继续输入enter键换行隔开。输入的任务完毕,此时按下ctrl+d,则会出现“at-> ”,此时输入完毕。屏幕底下会出现类似“job 3 at 2018-01-14 12:17”的字样,证明任务指定成功。
时间参考表
noon 12:00 PM October 18 2014
midnight 12:00 AM October 19 2014
teatime 4:00 PM October 18 2014
tomorrow 10:00 AM October 19 2014
noon tomorrow 12:00 PM October 19 2014
next week 10:00 AM October 25 2014
next monday 10:00 AM October 24 2014
fri 10:00 AM October 21 2014
NOV 10:00 AM November 18 2014
9:00 AM 9:00 AM October 19 2014
2:30 PM 2:30 PM October 18 2014
1430 2:30 PM October 18 2014
2:30 PM tomorrow 2:30 PM October 19 2014
2:30 PM next month 2:30 PM November 18 2014
2:30 PM Fri 2:30 PM October 21 2014
2:30 PM 10/21 2:30 PM October 21 2014
2:30 PM Oct 21 2:30 PM October 21 2014
2:30 PM 10/21/2014 2:30 PM October 21 2014
2:30 PM 21.10.14 2:30 PM October 21 2014
now + 30 minutes 10:30 AM October 18 2014
now + 1 hour 11:00 AM October 18 2014
now + 2 days 10:00 AM October 20 2014
4 PM + 2 days 4:00 PM October 20 2014
now + 3 weeks 10:00 AM November 8 2014
now + 4 months 10:00 AM February 18 2015
now + 5 years 10:00 AM October 18 2019