3

I am trying to get a cronjob in CakePHP work. But I am getting this error: Error: Class TestingShell could not be loaded.

Here is my /app/vendors/shells/testing.php file:

class TestingShell extends Shell    {
var $uses = array('Test');
function main(){
    $this->out('Number of tests :');
    $this->out($this->Test->find('count'));
    $this->out('.');
    if($this->Test->delete(1)){
        $this->out('test deleted'); 
    }
    else{
        $this->out('test not deleted'); 
    }
}

}

I am calling the cronjob like this: /home/root/public_html/site/cake/console/cake -app /home/root/public_html/site/app testing

What am I doing wrong? Thank you very much!

EDIT I must add that, locally, the shell works fine.

linkyndy
  • 17,038
  • 20
  • 114
  • 194

2 Answers2

2

Check out this bug report -- this was my problem.

http://cakephp.lighthouseapp.com/projects/42648/tickets/1601-cakephp-138-console-ignores-app-parameter

Rolling back to 1.3.7 was the quick fix.

Dan
  • 98
  • 7
  • 1
    You are golden! Thank you very much! Now it works! However, it still gives me an error, `TERM environment variable not set.`, but it does its job. Why is it throwing this error? And also, why isn't the 1.3.8 version working? How can it be resolved? Will I be able to make updates to Cake in future or will I face again this odd behaviour with the cronjob not working? – linkyndy Apr 28 '11 at 13:53
  • I believe they already fixed it in the development branch. I would expect 1.3.9 to work fine. The TERM environment thing is unrelated. – Dan May 08 '11 at 00:46
1

have a look at this, you may also need the added shell script

http://book.cakephp.org/view/1110/Running-Shells-as-cronjobs

you also have the params wrong way round, its

1 * * * * cake/path scritp params -app app/path

dogmatic69
  • 7,574
  • 4
  • 31
  • 49
  • I am not following that tutorial. I guided upon this: http://stackoverflow.com/questions/3192070/cron-job-with-cakephp . Anyway, I have tried this `/home/root/public_html/site/cake/console/cake testing -app /home/root/public_html/site/app` and it still doesn't work...the same error. I am quite a newbie to all cronjob/Linux/command line stuff, so I really don't get what is going wrong. But since it gives me that error, I believe the script found that it should be a TestingShell class somewhere (based on the `testing` command I wrote), but it couldn't find it. – linkyndy Apr 27 '11 at 20:54