octobercms/docs

CRON in October and Laravel are different

summercms opened this issue ยท 6 comments

October Doc's

Link: https://octobercms.com/docs/setup/installation#crontab-setup

*  *  *  *  * php /path/to/artisan schedule:run >> /dev/null 2>&1

Laravel Doc's

Link: https://laravel.com/docs/master/scheduling

*  *  *  *  * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

Would it be a good idea to update October Doc's ?

It was changed on Laravel's end in laravel/docs#4380, could you verify that the reported issue that documentation change is meant to fix actually exists? I'd rather we actually fix the underlying issue if there is one rather than make seemingly random changes to the docs, especially since there's a large user base out there that would have followed the existing docs to setup their scheduler runners.

@LukeTowers I have been looking deeper in cron jobs with regards to laravel and october and have come to the conclusion that both sets of doc's are wrong and need updating, I will try and list all the issues and points I have found in my testing and research, for you to review:

  1. php is misleading and it depends on the hosting company! Sometimes you will need to write the php location, some common examples are:
/usr/local/bin/ea-php72
/usr/local/bin/php
/usr/bin/php

It should be mentioned that you may need to use php or write the php location.

  1. >> /dev/null 2>&1 turns off sending emails, it should be mentioned that turning this off can be useful in testing to see if the correct cron has been setup.

  2. For writing:

php /path/to/artisan schedule:run >> /dev/null 2>&1

or

cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

Gave me different results depending on the hosting company, one worked on one hosting company and the other worked on another!

  1. Troubleshooting, a couple of common issues I found again and again while doing research into this was the following two errors:

4.a)

InvalidArgumentException: is not a valid CRON expression

You entered a wrong path for the php or path to artisan.

4.b)

ErrorException: Invalid argument supplied for foreach()

Depending on the hosting company, you may need to link to php-cli instead of php, common examples are:

PHP 7.2 - /usr/local/php72/bin/php-cli
PHP 7.3 - /usr/local/php73/bin/php-cli

Let me know what you think, adding this extra info may help people.

@ayumi-cloud

I worry that trying to cover everyone's edge cases in the docs is going to be exhaustive and fill the document with too much info. Where possible, we should be trying to promote the most common setups, and maybe some helpful hints for people who have custom configurations, but that is all.

php is misleading and it depends on the hosting company! Sometimes you will need to write the php location, some common examples are:

I think it goes without saying that php may be located in different locations, depending on the host provider or the OS they run. That's why it's usually safer to just have the docs say only php, as most hosts would've setup php to be found within the user's PATH environment variable.

/dev/null 2>&1 turns off sending emails, it should be mentioned that turning this off can be useful in testing to see if the correct cron has been setup.

Just to make it clear - that suffix doesn't turn off emails from the app - it turns off emails that may have been sent by the crontab runner itself (generally, this is the output of the program run).

@LukeTowers @bennothommo

As I'm getting such a wide range of results and not really happy to give an exact answer, would you both be happy if I closed this?

Eoler commented

Let me know what you think, adding this extra info may help people.

@ayumi-cloud this is probably the material for a support article: https://octobercms.com/support
(could be also linked from docs)

@Eoler yah I agree it would be nice to add it there under a section called: Troubleshooting. But I rather keep quiet and give up trying to argue the case against the politics here.