Cron Job and CLI |
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? (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
(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.
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. |
Welcome Guest, Not a member yet? Register Sign In |