How to setup cronjobs in cake php?

Use a shell

The 'Cake Way' of using a CakePHP application in cron jobs would be creating shell and then calling it as a cron job.

i.e. Create a shell to do the task, and then add it to crontab (crontab -e on linux machine):

0 * * * *       cd /path/to/app/ && Console/cake your_shell_name params

Creating shells and using them with cron is covered in the documentation.


Since we dont need the View layer of MVC, i will also suggest to use Cake shell instead of writing it in normal controllers. This will also reduce the memory load of various callback functions of controllers like beforeFilter, beforeRender et al.

Then make an entry in **nix cron tab for crons written in your CakeShells.