As our application grows in size and complexity, we will find ourselves in the need to create and automate certain tasks, deferring the processing of non-interactive tasks for later execution. While we can create shells to perform these operations, some of our needs may be met by the Robot plugin.
Note
While this recipe shows a pure CakePHP approach, there are more involved and scalable alternatives. One of the most used tools is Gearman, available at http://gearman.org/.
The Robot plugin allows us to schedule tasks for later execution, and have those tasks run by a shell. The tasks themselves are actually CakePHP controller actions, which are run by the shell at the specified time.
This recipe shows us how to use the Robot plugin to send an e-mail after a user has signed up for our newsletters, and how to have the shell in the Robot plugin periodically check for pending tasks and run them as they become available.