简体   繁体   中英

Setting Up Laravel Scheduler on Production Server (Inmotion Hosting)

I have come to realize that how you write the cron for the laravel scheduler varies from hosting to hosting so the docs are useless in this case.

The same code I used on my previous host(siteground) does not seem to be working on my current one(inmotion).

The cron that runs the scheduler, the one I set from my CPanel seems to work:

php -q /home/xxxxx/xxxxx/artisan schedule:run

I say it seems to work because I get this email whenever my cron runs:

Running scheduled command: /usr/bin/php -q /home/xxxxx/xxxxx/artisan {command} > '/dev/null' 2>&1 &

Now the above script does not seem to execute it just hangs and the processes pile up eating my memory until my entire server crashes.

So I'm quite confused here, why does php -q /home/xxxxx/xxxxx/artisan schedule:run execute but somehow my app is unable to execute /usr/bin/php -q /home/xxxxx/xxxxx/artisan {command}

I googled it and several suggestions where to use php-cli instead of php -q but php-cli gives me a command not found error.

So I asked support about this and this is what they said:

I am not certain how you were able to run that command with another host, as php-cli is not a command for the php command line interface. Unfortunately, because this is not a valid command, I am not sure if I understand what you are trying to accomplish by running it.

php -q is the option that executes php-cli, which is what you should be using for your crons; however it will only properly execute if the coding of the file that you are executing is correct.

I have been on this for 2 days now, my question is how do I get my laravel scheduler to execute without any errors, does anyone have any experience with deploying a laravel(lumen) application on inmotion servers or similar? Thanks in advance. :)

So it may have had something to do with the cli php version still not certain but i finally got it to work with this:

/usr/bin/php -ea_php 70 -q /home/xxxxx/xxxxx/artisan schedule:run

and then I edited my Illuminate/Console/Scheduling/Schedule.php file on line 49 to this:

return $this->exec("/usr/bin/php -ea_php 70 -q /home/xxxxx/xxxxx/artisan {$command}", $parameters);

Seems to work now. :)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM