Cronjob does not recognize the CodeIginiter controller

1

I'm trying to make a cronjob run in the CI, but I'm not getting it, this error appears:

  

Fatal error : Class 'CI_Controller' not found in /MeuCaminho/application/controllers/cron.php on line 4

>

PHP

<?php 
class Cron extends CI_Controller{ 
//put your code here 
public function index(){ 
    $arq = fopen("teste_cron.txt", "a+"); 
    fwrite($arq, "=======================TESTE CRONTAB======================================\n"); 
    fwrite($arq, "O CronTab executou este código na Data/Hora: ".date("d/m/Y H:i:s")."\n"); 
    fwrite($arq, "==========================================================================\n"); 
    fclose($arq); 
}} 

PATH

php -q /home/user/public_html/caminho_completo/application/controllers/cron.php 

Can anyone tell me how I can do it?

    
asked by anonymous 14.04.2015 / 23:23

1 answer

0

The error seems to be in the way you call the script from the command line. According to the manual , you need to navigate to the project folder and run index.php , passing for him controller and action:

cd /home/user/public_html/caminho_completo/application/
/caminho-do-php/php index.php cron index
                               |     |
                               |   action
                          controller
    
14.04.2015 / 23:44