开发者

storing crontab php outputs in a log file

* * * * * php /home/admin/public_html/domain.com/public/cron/route.php &>> /home/admin/public_html/domain.com/log/cron.log

I have that cron running every minute.

I want to store the errors that occur in route.php in cron.log

This works wonderfully when I run :

php /home/admin/public_html/domain.com/public/cron/route.php &>> /home/admin/public_html/domain.com/log/cron.log

through the command l开发者_如何学JAVAine manually. But when crontab runs it no errors gets stored in cron.log

the cron.log is owned by admin:admin and the permissions are set to 777 just to be sure.

anyone?


Something like this:

* * * * * /usr/bin/php /home/admin/public_html/domain.com/public/cron/route.php >> /home/admin/public_html/domain.com/log/cron.log 2>&1

Where the standard error is redirected to the same destination as standard output (with 2>&1), this will collect any errors outside of the script and add them to the cron.log file.


This can be simply called with > symbol on cron or php -q or -f command.

On your case

php -q /home/admin/public_html/domain.com/public/cron/route.php > /home/admin/log.txt 2> /dev/null

Blockquote php -q /home/admin/public_html/domain.com/public/cron/route.php > /home/admin/log.txt 2> /dev/null

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜