How can I use cron job in cakephp to call an action of a controller on Ubuntu, I am trying to do it through crontab but it is not working?
This can be done very easily by the following steps -:
1) Create a shell let's say HelloShell.php in Console/Command
This shell can be called by Console/cake hello
2) Write the command crontab-e
.This will open up the default editor or the editor which you select
Now as we want that our shell should run after every 5 minutes write:-
*/5 * * * * /PATH TO APP/Console/cake hello
For better understanding refer https://www.youtube.com/watch?v=ljgvo2jM234
3) If you want to call the action of the Controller in Shell simply import that particular controller let's say AppController by App::uses('AppController', 'Controller');
Now create the object AppController in Shell by
$object =new AppController();
$object->func_in_controller();
Now the parameters of function can be accessed in the Shell by $object->func_param;
Thanks!