开发者

Cron Job PHP script execution time report

My question is simple: I want to know how long a PHP script is taking to execute. On top of this, I am executing it via 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?

Currently I am using:开发者_StackOverflow中文版

/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

:-)


You can use time command like this:

/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.

$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); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜