skip to Main Content

I am using codeigniter 3.1.3 with modular extensions. I have a command for a cron job but it does not seem to work in my cpanel. The cron job is supposed to run every half hour

 0,30   *   *   *   *   php-cli /home/username/public_html/index.php/module_name controller_name method

2

Answers


  1. First 0,30 is a single parameter, so you need to add one more. Also you’re not calling your Codeigniter function correctly. The standard syntax looks like this:

    0,30   *   *   *   *   *  php-cli /home/username/public_html/index.php/module_name/controller_name/method_name parameters
    

    I left in the ‘module_name’ segment of the of the URL even though I’m not sure too familiar with HMVC, and I’ve seen different structures in what little I have seen, so change the order of those if appropriate.

    Login or Signup to reply.
  2. Use the following command

    0,30   *   *   *   *   php /home/username/public_html/index.php/module_name controller_name method
    

    Get rid of defined('BASEPATH') OR exit('No direct script access allowed') in the controller and any model that the controller is loading

    You can read more about running from the command line from the codeigniter documentation

    https://www.codeigniter.com/userguide3/general/cli.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search