mercredi 30 août 2017

is it possible to change the path to PHP that the Laravel task scheduler uses

I have a Laravel 5.4 app which is on shared hosting and the cron job isn't working. I have set the command up in the kernel.php like so:

$schedule->command('eoddsmaker:get_events')
         ->withoutOverlapping()
         ->appendOutputTo(storage_path('logs').'/cron-get_events.log')
         ->everyMinute();

And if I just run /usr/bin/php-5.6 artisan eoddsmaker:get_events from the command line it runs fine. When it gets called by the cron job though it doesn't run. This is my cron definition:

* * * * * /usr/bin/php-5.6 /var/sites/c/http://ift.tt/2wIVAWA schedule:run >> /var/sites/c/http://ift.tt/2wo7HWw 2>&1

I can see from the cron logs on the server that this task is running every minute and everytime that it runs the following output gets added to the cron.log file:

Running scheduled command: '/usr/bin/php' 'artisan' eoddsmaker:get_events > '/dev/null' 2>&1
X-Powered-By: PHP/5.6.8
Content-type: text/html; charset=UTF-8

So to dig a bit deeper if I look in the cron-get_events.log file that I have configured the task to send output to the following gets output every time it runs:

Warning: Unexpected character in input:  '\' (ASCII=92) state=1 in /var/sites/c/http://ift.tt/2wIVAWA on line 31

Parse error: syntax error, unexpected T_STRING in /var/sites/c/http://ift.tt/2wIVAWA on line 31

Because I'm on shared hosting the default PHP version is 5.2 and I have to add a rule in the htaccess file to get it to use PHP 5.6. If I forget to add the rule I get the same error as the one that is in the cron-get_events.log so this leads me to believe that the reason the command isn't working is because when the scheduler runs it is calling the command with /usr/bin/php as the path to PHP rather than /usr/bin/php-5.6

Is there a way to configure the task scheduler to use a different path to PHP?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wISxxD
via IFTTT

Aucun commentaire:

Enregistrer un commentaire