Run Cronjob Codeigniter

Asked

Viewed 950 times

2

How to execute a class method in Codeigniter via Cronjob?

Ex: main.php accessed in http://www.meusite.com.br/principal/listaCron

<?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’));
  }

}

2 answers

1

Follow the manual link for this http://www.codeigniter.com/user_guide/general/cli.html.

on my site 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 Curl

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

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.