Alessandro Minoccheri
Alessandro Minoccheri

Reputation: 35973

Codeigniter class cron doesn't work

I have a site developed in codeigniter where I want to use a cron controller. I have write this controller:

class Cron extends CI_Controller {

    function __construct()
    {
        parent::__construct();

        // this controller can only be called from the command line
        if (!$this->input->is_cli_request()) show_error('Direct access is not allowed');
    }

    function importMeteo()
    {
        $this->load->model('Meteo_model');
        $this->Meteo_model->importFromXml();
    }
}

The function importFromXml works fine because if I call it from other controller no problems.

Into my linux server in /etc/crontab I have added this line to call this functuon every 10 minutes:

*/10 * * *      root    php /var/www/public/my_site.com/index.php cron/importMeteo

But I don't see any change like the function isn't called.

I'm wrong something?

Upvotes: 0

Views: 173

Answers (1)

nana.chorage
nana.chorage

Reputation: 506

cron entry should be like this

*/10 * * * * php /var/www/public/my_site.com/index.php cron importMeteo

Upvotes: 1

Related Questions