Run Cronjob Codeigniter

2

How to execute a method of a class in Codeigniter via CronJob?

Ex: main.php accessed at link

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Principal extends CI_Controller {

  public function __construct()
  {
    parent::__construct();
    //Load Dependencies     
  }

  public function listaCron()
  {     
     file_put_contents("teste.txt", "Crontab executado em: ".date(‘d/m/Y H:i’));
  }

}
    
asked by anonymous 21.10.2014 / 22:07

2 answers

1

Follow the link for the link .

In my place I left to run like this:

0 1 * * * php /var/www/meusite/index.php principal listaCron

But on the server I had to run through the curl

0 1 * * * /usr/bin/curl -L --silent http://www.meusite.com.br/index.php/principal/listaCron
    
10.11.2014 / 17:43
0

If your server has support for curl , you can add this to the Crontab command line:

curl link

    
10.11.2014 / 17:09