I had a scheduled task for mailing out cryptograms to subscribers. This was initially set to run every two minutes and then the task would use cfschedule to update the start time if all the email had been sent.

I discovered a bug in the task when an email had passed my (obviously deficient) validation and so deleted the task with the CF Admin while I corrected it. To my amazement the task kept running anyway. Restarting CF did not solve the problem.

My panic solution was to delete the cfm the phantom task called. This worked but, of course, led to lots of entries in the error logs so I replaced the now missing page with a template that did nothing. That provided an inelegant but viable solution.

As a result of this I decided that any scheduled task I create should be a "run once" task and then to have the template called regenerate the scheduled task. This worked fine until the site was down when the scheduled task was due to run. In that case CF dutifully reported that the task errored out but since it was a run once task it considered it's job done.

Hmmh. What to do, what to do.

If I had a list of existing tasks in the scheduler I could then make sure everything was present. Unfortunately there is no documented way to retrieve that list.

Fortunately Ben Forta's blog had a solution: here

With that I was able to create a template which regenerated missing tasks.

Ok, fine but I don't want to run that as a reoccuring task, given my experience with phantom tasks.

My solution was to create a cron job which used curl to serve the template.

view plain print about
130 * * * * curl -u xxx:yyyy http://<urltotemplate>
This method seems to work fine.