[英]Cron Job PHP script execution time report
My question is simple: I want to know how long a PHP script is taking to execute. 我的问题很简单:我想知道PHP脚本执行的时间。 On top of this, I am executing it via cron.
最重要的是,我通过cron执行它。 Now, I could do something via the PHP code itself to get the execution time start/end, however I wondered if there was something via the cron command that I could add to get that emailed to me, in milliseconds?
现在,我可以通过PHP代码本身来做一些事情来获得执行时间的开始/结束,但是我想知道是否有通过cron命令的东西我可以添加以通过电子邮件发送给我,在几毫秒内?
Currently I am using: 目前我正在使用:
/usr/bin/php -q httpsdocs/folder/script.php > /dev/null 2>&1
Which runs my script and stops all errors/output getting emailed to me. 哪个运行我的脚本并停止通过电子邮件发送给我的所有错误/输出。 Can I change the above to get the execution time emailed to me somehow?
我可以改变上面的内容,以某种方式通过电子邮件将执行时间发送给我吗?
Thanks 谢谢
/usr/bin/time /usr/bin/php -q httpsdocs/folder/script.php
| mail -s "Some Subject" you@youremailid.com
:-) :-)
你可以使用这样的time
命令:
/usr/bin/time /usr/bin/php -q httpsdocs/folder/script.php > /var/log/crontiming
By the given script you can change the cron job execution time. 通过给定的脚本,您可以更改cron作业执行时间。
$aCronList = array();
$result = -1;
exec('crontab -l', $aCronList, $result);
foreach($aCronList AS $item)
{
// Find what you want, replace the times
}
$sCronList = implode(PHP_EOL, $aCronList);
exec('crontab < ' . $sCronList);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.