I'm using Laravel 4 to build my site, and I just created a new command that backs up my database and does a few database updates. Calling it on my computer through windows command prompt works fine:
php artisan dbupdate
But when I try to use it as a cron job on my shared host server like this:
1 * * * * php -q /home/******/laravel/artisan dbupdate
I get the following error:
Failed to start the session because headers have already been sent by "" at line 0.
I thought it might be something in my code, so I commented it all out and just put a echo "hello command" line in to test it, but I still got the same error. It's coming from laravel/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
I'm pretty new to Laravel and quite new to cron jobs. What could be the problem?
I tried using php-cli instead of php as in this post
So my cron job now looks like this:
1 * * * * php-cli -q /home/******/laravel/artisan dbupdate
And though I still don't quite understand what's different about this, it works perfectly.
In short you'll be attempting to send a header after having already sent some output. I can't tell from what you've put but it's likely that somewhere in the code you have an include() function.
For a full explanation of the causes and fixes look here - https://stackoverflow.com/a/8028987/1566393
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.