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:
/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" [email protected]
:-)
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With