Additional Considerations

As useful as the ColdFusion Scheduler is, it does have its limitations. One of the most notable limitations of the Scheduler is that there is no built-in redundancy. That is, if a scheduled task fails to execute for whatever reason (say the server is down) the Scheduler has no way of knowing this condition and only attempts to execute the task again the next time it is scheduled for execution.

It is possible to build redundancy into your scheduled tasks, but it takes work. One solution involves creating a small database that contains a record for each entry in the Scheduler. Each time you execute a scheduled task, you cfinclude a file or call a custom tag that updates a field in the database with the time and date that the task should be executed next. A second template scans the database of scheduled tasks and checks to make sure none of the tasks have a time/date for next execution that is older than the current time/date. If so, you know that the task didn’t execute for some reason, and you can call the cfschedule tag to immediately try to run that task again. The template that performs the scan should itself be scheduled to run at an interval that is appropriate for your particular needs (i.e., every 15 minutes, every 30 minutes, etc.).

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.