There has been quite a few threads about the best way to run cron jobs
when using CakePHP. I had to do this for my own application and I am
happy with the result so I want to share it with everyone. I can't take
all the credit for this as it's based on Jason Lee's post in the
thread:
http://groups-beta.google.com/group/cake-php/browse_thread/thread/ff3ad3c9e1e40aab/
It involves hacking the dispatcher so you can call controller actions
via the command line. What you do is make a copy of index.php in
/app/webroot/, scroll to the bottom and when you come to the line -
require CORE_PATH.'cake'.DS.'bootstrap.php'; - replaces everything
below it with the following code:-
// Dispatch the controller action given to it
// eg c:\php4\cli\php cron_dispatcher.php /mailouts/send
if($argc == 2) {
$Dispatcher= new Dispatcher();
$Dispatcher->dispatch($argv[1]);
}
What this means is you can call controller actions from the command
line, so for example to call the send action in your mailouts
controller you just create a cron job like this:
php cron_dispatcher.php /mailouts/send
Hope people find this useful.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---