Multiple templates running concurrently


I have scheduled a coldfusion template to run every 10 minutes how do i prevent it from running when the previous run exceeds 10 minutes.

I've tried using a counter variable in the application scope unfortunately when the template times out or errors out the counter is not decremented.

PS. Is there a coldfuison framework for integrating applications (backend stuff)


Use an exclusive named <a href="http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_j-l_05.html" rel="nofollow">cflock</a>:

<cflock timeout = "#createTimeSpan(0,0,0,1)#" name = "myProcess" throwOnTimeout = "no" type = "exclusive"> <cfset start = now()> <!--- CFML to be synchronized. ---> <cfset interval = 10 * 60> <!--- 10 minutes in seconds ---> <cfif dateDiff("s", start, now()) GT interval> <cfhttp url="yourtemplate.cfm"> </cfif> </cflock>

This ensures only thread ever runs the block of code in question. Simultaneous access will fail in one second without error.

To ensure the next run gets kicked off if the prior exceeds the time interval, track the start time inside the lock and then at the end, if its exceeded the interval, have the last statement inside the cflock be a cfhttp call to itself.


One possible route you could explore:

You could set up a database table to track the progress of the task. Maybe table name "task", with columns "taskName" and "inProgress", with the latter being a boolean. When the task starts, set inProgress to true. When it finishes, set inProgress to false.

In the template called by the scheduled task, have it first check the "inProgress" status of the specified task. If it's true, just abort. Otherwise, proceed.


Hmm... that actually wouldn't work any better than your application variables in the case of timeouts or errors. So now thinking that instead of a boolean, you use a timestamp. When the scheduled task fires, update the value with the current time. When it finishes, clear it out.

So when the task starts again, it will see that the previous task either finished (a null value), or it's still in progress. -If- it's still in progress, you can do a dateDiff() on the value to see if it was more than 'x' minutes ago. If it was, you can assume the previous task timed out (or errored out... but in that case I'd think you could put some error handling into the task itself) and run the current instance of the task.


  • Cannot register REST services
  • For HTML Emails, How to embed images so users don't get a download prompt
  • ColdFusion Components Inheriting Functions Of Others
  • Need to Fetch the specific data from external page
  • insert operation into a bigquery table
  • Is it possible to have dynamically generated query names in ColdFusion?
  • SQL to Excel loses trailing zeros
  • java rmi deadlock
  • Powerpoint 2010 VSTO AddIn taskpane on multiple Windows
  • MySql - get days remaining
  • data.table replicate rows after join?
  • oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Invalid JWT
  • Runtime.exec() gives Error: Could not find or load main class
  • print() is showing quotation marks in results
  • Record samples being played with OpenAL
  • Q promise. Difference between .when and .then
  • Illegal mix of collations for operation for date/time comparison
  • Hazelcast - OperationTimeoutException
  • Websockets service method fails during R startup
  • Alternatives to the OPTIONAL fallback SPARQL pattern?
  • How to get next/previous record number?
  • Apache 2.4 - remove | delete | uninstall
  • retrieve vertices with no linked edge in arangodb
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • File upload with ng-file-upload throwing error
  • Proper way to use connect-multiparty with express.js?
  • python regex in pyparsing
  • Trying to get generic when generic is not available
  • embed rChart in Markdown
  • Change div Background jquery
  • Android Google Maps API OnLocationChanged only called once
  • How to get Windows thread pool to call class member function?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal
  • How can I use threading to 'tick' a timer to be accessed by other threads?