Cron Job and CLI - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: Cron Job and CLI (/showthread.php?tid=75402) |
Cron Job and CLI - Roddyguy - 02-02-2020 I have setup a cron job and call it like this: php /home/sitename/public_html/www/index.php controllername method If I connect to my server using SSH (putty) and call this command, everything runs just fine. But when my account cron job runs (using same command) I receive an email from my server displaying the HTML from my home page. It appears it is ignoring the controller and method calls. CI_VERSION = '3.1.9'; My server is CentOS 6 WHM CP. Any ideas what is happening? RE: Cron Job and CLI - Goddard - 02-04-2020 Try putting the command in a shell script and running that. RE: Cron Job and CLI - Roddyguy - 02-05-2020 (02-04-2020, 12:08 PM)Goddard Wrote: Try putting the command in a shell script and running that. Same results running in shell script -- grabbed the index page and ignored controller and method. However, I did find the answer - I had to be more specific about the PHP version I was running: Code: /opt/cpanel/ea-php71/root/usr/bin/php /home/accountname/public_html/www/index.php controller method I have no idea why this would make a difference, but it does work now. I do not have to use full path PHP calls for other cron jobs (that don't include controller and method) I just call: Code: /usr/bin/php /home/accountname/public_html/www/filename.php RE: Cron Job and CLI - dave friend - 02-05-2020 (02-05-2020, 08:03 AM)Roddyguy Wrote: I have no idea why this would make a difference, but it does work now. Some OS distributions use a different php.ini for the CLI than is used for Apache (or other httpd). Perhaps that ini is pointing to a different version of PHP? RE: Cron Job and CLI - Roddyguy - 02-05-2020 (02-05-2020, 09:23 AM)dave friend Wrote:Thanks Dave. Makes sense.(02-05-2020, 08:03 AM)Roddyguy Wrote: I have no idea why this would make a difference, but it does work now. RE: Cron Job and CLI - versigtm - 04-08-2020 Hey there! Thank you for posting this. I was pulling my hair out because I couldn't pass the controller and the method in the cron job... I confirm that by using the full path to the php compiler - in my case /usr/local/bin/php - it worked. |