Search code examples
codeigniter-3cron-task

Codeigniter Cron job problems - CI Version 3.1.9


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'; SERVER is CentOS 6 WHM CP.

Any ideas what is happening? I would rather not use the CURL method. Script times out.


Solution

  • I found the answer, though not sure why this works:

    I had to be more specific about the PHP version I was running:

    /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:

    /usr/bin/php /home/accountname/public_html/www/filename.php