ubuntu - Log Output from php file during cron job -
i running cron job on local server running ubuntu 13.10 , want create log of jobs performed. can access main log file, syslog, shows if cron job ran or had errors.
here cronjob (runs every minute while testing, script finished in under few seconds)
* * * * * /usr/bin/php -f /home/[usr]/web/x/app/application.php &>> /home/[usr]/maildir/geocode.log 2>&1 # job_id_2 inside application.php file, have several echos output variables , results of queries performed:
echo "starting cron @ ".date("m-d-y h:i:s")."\r\n"; echo count($properties) . " properties query"."\r\n"; if run file command line, file executes correctly , output displayed. after looking other questions cron logs, thought needed output log file second half of cron job:
>> /home/[usr]/maildir/geocode.log 2>&1 is incorrect? how can save , log output php file? file selects number of object database , performs actions on them. want output number worked on, number completed, , errors. right nothing outputted, know cron running because database connects being updated correctly.
edit: researched more , thought 2>&1 pass stderr stdout because wanted of info, looks preventing being written. using:
/usr/bin/php -f /home/[usr]/web/x/app/application.php >> /home/[usr]/maildir/geocode.log adds of output expecting log file, unsure happen errors because running fine now. leave open in case else wants add creating log file , if 2>&1 should ever used in situation want keep both stderr , stdout.
Comments
Post a Comment