Cron Job PHP script runtime report

My question is simple: I want to know how long the PHP script has been running. In addition, I execute it through cron. Now I could do something using the PHP code itself to get the start / end time, however I was wondering if there was anything with the cron command that I could add to get it by email in milliseconds?

I am currently using:

/usr/bin/php -q httpsdocs/folder/script.php > /dev/null 2>&1 

Which launches my script and stops all errors / output messages sent to me by email. Can I modify the above to get the lead time for emailing me somehow?

thanks

+4
source share
3 answers

You can use the time command as follows:

 /usr/bin/time /usr/bin/php -q httpsdocs/folder/script.php > /var/log/crontiming 
+3
source
 /usr/bin/time /usr/bin/php -q httpsdocs/folder/script.php | mail -s "Some Subject" you@youremailid.com 

:-)

+5
source

With a 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); 
+1
source

Source: https://habr.com/ru/post/1332837/


All Articles