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 line 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?

Answers


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


Need Your Help

Authentication Challenge

iphone ios authentication webview alertview

i try to access a protected webfolder with the webview. with "hard coded" user and pass it works, but my plan is to pop up an alertview to enter user and pass. here is the part of code:

REST/Ajax deep linking compatibility - Anchor tags vs query string

html ajax http hyperlink

So I'm working on a web app, and I want to filter search results.