Search code examples
coldfusionscheduled-taskscfccoldfusion-8

How can I run a ColdFusion scheduled task at an interval <60 seconds?


I have a CFC method that I would like to run at an interval of 30 seconds. However, the problem is ColdFusion won't let me schedule a task that runs at an interval of 60 seconds or lower. Does anyone have a suggestion about how I can (and should) accomplish this?

To preemptively answer the question "What happens when your script runs longer than 30 seconds," or any other question like that, I have already taken all that under consideration and it is not a concern.

I'm running ColdFusion 8.0.1 (w/ hotfix 4) on Windows Server 2003 (IIS6). As a side note, I'm using Java 1.6u21 as my JVM for ColdFusion.

Thanks in advance.


Solution

  • The only way to do this is with some manual editing of the file for your scheduled tasks.

    So:

    1. Create the scheduled task with an interval of say 5 mins.
    2. Open the file called neo-cron.xml in the lib directory of your CF install. You might want to back it up first.
    3. Search for the name of your scheduled task. It's a big chunk of XML so you might like to format it and search for it in a XML editor.
    4. A little after the name of the task you should see something like this: <var name="interval"><string>300</string></var>. This is the number of seconds between when the task runs. It's in seconds here, so you can manually adjust it to 30 and then save the file and close it.

    This will still show as 1 min in the CF admin but it should run every 30 seconds - add logging to prove it if you wish!

    Not that if you edit any other scheduled task using CF admin your manual changes will be unaffected, but if you edit the actual task you manually adjusted it will overwrite your changes.

    Hope that helps!