Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Tasks do not work with cronjob
#4

Hi,
Some of the example cron statements in the CI documentation can be misleading especially where hosted and shared hosting environments are concerned, but then they are examples. Certainly in my case (shared hosting with cPanel), CI examples look more like Terminal commands rather than a scheduled CRON.

For example via Terminal I would cd (change directory to my target folder) then execute with: php spark command:run.
While a scheduled CRON command line would look more like /hosted/path/to/php /home/myserver/myfolder/spark command:run.

My shared hosting provider (using cPanel) recomended prepending all of my cron jobs with CRON_MODE=1, due to it's specific php configuration and use.
I also have to reference where (on the server) the php is being call from, directly in the command line.


For example, where my shared hosted environmet is

Code:
/home/myserver/myfolder/mydomain.com


where myfolder stores my codigniter files (app, public, system, etc), and mydomain.com is my public folder (renamed).


Therefore to get a CRON to call a named route (note the space after index.php)
Code:
CRON_MODE=1 /hosted/path/to/php /home/myserver/myfolder/mydomain.com/index.php namedroute


To get CRON call a command (note the path to the file location, exclude php and NO space before spark)

Code:
CRON_MODE=1 /hosted/path/to/php /home/myserver/myfolder/spark command:run


Note: I have have a CRON running every minute executing Tasks
Code:
CRON_MODE=1 /hosted/path/to/php /home/myserver/myfolder/spark Tasks:run



I hope this helps!
Reply


Messages In This Thread
RE: Codeigniter Tasks do not work with cronjob - by 68thorby68 - 09-16-2024, 12:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB