Duncan's blog

April 14, 2009

ColdFusion scheduled task bug

I just discovered this bug with scheduled tasks in ColdFusion Administrator today. I think I’ve encountered it before but didn’t realise at the time what had happened.

I was updating a scheduled task to run in the future. I then decided to just run it manually instead. To make sure the scheduled task didn’t run as I’d originally planned, I just put the date into the past. I didn’t want to delete the scheduled task as it’s one that is run occasionally as and when required.
ColdFusion Administrator scheduled task screen

What I found was that when I edited the scheduled task to be in the past, it actually ran immediately! If you edit it again to another date in the past, it’ll run again. Luckily the scheduled task I was working on wasn’t that important, but some scheduled tasks (especially one-off ones) might have more serious consequences if they run when you’re not expecting it.

I found two ways to replicate this bug.
Method 1:

  1. Create a new scheduled task in CF Administrator.
  2. Set it to run one time with a date in the past, say yesterday at 9pm.
  3. Save the scheduled task.

Method 2:

  1. Create a new scheduled task in CF Administrator.
  2. Set it to run one time with a date in the future, say tomorrow at 9pm.
  3. Save the scheduled task.
  4. Edit the scheduled task, and change the date or time to the past, say 9pm yesterday.

So basically any time you create or update a scheduled task, running ‘One-Time’ but with a date/time in the past, it’ll run immediately!

I noticed this bug in Adobe ColdFusion 7 and 8 Enterprise, and ColdFusion 8 Developer edition. I’d be surprised if it happens in Railo or OpenBlueDragon. Bug reported at Adobe’s Bug Report Form.

Advertisements

3 Comments »

  1. […] bug, cfml, cfschedule, Coldfusion, scheduled tasks In a follow-up to yesterday’s post about a bug with scheduled tasks in ColdFusion Administrator, I decided to see if the same bug existed if you used the <cfschedule> […]

    Pingback by CFSchedule bug « Duncan’s blog — April 15, 2009 @ 8:06 pm | Reply

  2. From the CF8 livedocs:

    “If you schedule a job to run once, the starting time is in the past, and the task has not yet run, it runs immediately. If you schedule a recurring job with a start time in the past, ColdFusion schedules the job to run on the next closest interval in the future.”

    http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_r-s_11.html#1843993

    Had the task already been run?

    Comment by Shaun — June 23, 2009 @ 4:07 pm | Reply

  3. Hi Shaun. Yes, the task had already run. However I hadn’t noticed that line in the documentation before, which clarifies that it’s not a bug but a ‘feature’! I was only setting this up as a one-time task, not recurring, so it did what it was supposed to I guess. Not what I would have expected though…

    Comment by duncan — June 27, 2009 @ 9:02 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: