Scheduled Task Start Time
I have been using ColdFusion since the 20th century and I thought I understood how it worked pretty well by now. I am not sure how this one slipped by me.
On one site, we have some aggregate reports that pull together fairly large amounts of data. When I first wrote the reports, they ran fine. As the site usage went up, however, these reports started taking too long to load. As a result, I had a friend of mine write some code to aggregate the data every night so that they would load quickly for the user. We tested the reports and everything worked great.
Recently, however, I noticed that the data seemed off. I couldn't find any problems, so I called my friend and he quickly saw (as I should have) that the nightly aggregation hadn't been run in a while.
He asked if the scheduled task was working. I said I knew that it was because I only have one scheduled task and the same page fires off a weekly email that has been working. Clearly, however, the code had not been executing.
I looked at the page being called by the scheduled task and found this:
<!--- call to reporting CFC here --->
</cfif>
Now I believed that this would have to run for an hourly task. I checked the task in the ColdFusion Administrator and verified that task was hourly. It was, so I could see no reason for this not to work.
Desperate, I changed the "LT" to an "LTE" and checked back the next day - still nothing.
Then the answer (and my misunderstanding) became clear:
The start time for the task was "11:00 AM". My understanding had always been that the start time just meant that the first time the task ran, it ran on that time on the start date, and then every hour (24 hours a day) from there on. This seems not to have been the case.
I changed the start time to "1:00 AM" and found the next day that the report had run.
I believe that this was working before we upgraded to CF8, so this may be a change in CF8. I have not had time to test that hypothesis, however.
So, always make sure that your start time precedes any task that you want to run.
That certainly appears to be the case - I'm not sure how I got myself all mixed up about it.
So your Scheduler is set to 'hourly', then this should only execute on the 3rd hour - assuming 1x a day then right? (as a time of 3 pm returns 15 as the hour)
So yes, I could see, setting up a Scheduler for 11 am would not work - even though, the next day - hourly, a person would think that the task would roll to the next hour in the morning etc.
The key here is to look at the scheduler log - and look for the 'Rescheduling for' value - as when a scheduled event ends - it should setup the next schedule for you. (make sure you log scheduled tasks etc - cfadmin Debugging and Settings - Logging Settings Enable logging for scheduled tasks)
I'm currently in a thread on the yahoo 'coldferusion' group about a scheduled task issue I'm seeing and is repeatable regarding long running threads, if interested http://tech.groups.yahoo.com/group/colderfusion.
That is correct. Certainly, I could have just set up a daily scheduled task to run at 3:00 AM for the same effect.
I avoided doing so only because I have one file on this site through which I manage all scheduled tasks - keeps me from having to clutter up the admin with a bunch of scheduled tasks some of which have rather complicated logic for determining the timing.
Good advice about looking at the scheduler logs - I certainly should have done that.