Codeigniter Tasks do not work with cronjob |
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! |
Messages In This Thread |
Codeigniter Tasks do not work with cronjob - by heruii - 07-11-2024, 06:25 PM
RE: Codeigniter Tasks do not work with cronjob - by heriniaina - 08-28-2024, 01:45 AM
RE: Codeigniter Tasks do not work with cronjob - by kenjis - 08-28-2024, 05:45 PM
RE: Codeigniter Tasks do not work with cronjob - by 68thorby68 - 09-16-2024, 12:05 PM
|