skip to Main Content

I have to use a cron job in cpanel and I am using CodeIgniter. My controller path is http://www.example.com/myfolder/application/controllers/cron/cron_controller.php How am I call my controller in cron.

3

Answers


  1. In the crontab simply define

    0 * * * * php /controllers/cron/cron_controller.php
    

    it will work, Here * are variables (time)

    Example of job definition:
    .---------------- minute (0 - 59)
    |  .------------- hour (0 - 23)
    |  |  .---------- day of month (1 - 31)
    |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
    |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
    |  |  |  |  |
    *  *  *  *  * user-name command to be executed
    
    Login or Signup to reply.
  2. When you’re trying to run cron, you’re running from the command line, but you’ll still need to go through the index. So your cron command would be:

    * * * * * php index.php cron cron_controller
    

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

    Login or Signup to reply.
  3. this is working . just type this in cron tab

    wget www.yourdomain.com/index.php/yourcontroller/yourfunction
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search