ColdFusion Scheduled Tasks

If you're running your own CF server, or are hosting with a host who's willing to do a little extra work for you, you're going to love ColdFusion scheduled tasks. It's basically a way to tell CF to run a particular file at a set interval. The called file can run a report, update a database, do an XML grab, anything you want. And then you can tell CF that you want it to save the results of the file somewhere else.

I used this to great effect today, hence my post :). changed their DesDev feed, so the XSL I slaved over in VBScript wasn't doing the trick for me, and I didn't feel like writing a new one :). So I built a CF page to consume the XML feed and do it's wonders. Well that's all fine and good, but DWfaq is built in asp, so I couldn't call the CF page from my ASP application files. Scheduled tasks to the rescue :D

I set up a scheduled task to run my des dev parser once every 4 hours. When the parser runs it saves the result as a plain old HTML file which I can then include into my .asp pages. This means I don't have to parse the XML feed everytime someone hits my site, and I don't even have to worry about the MM server not being responsive but once every 4 hours (a pretty decent gamble given that I'm error checking things anyway).

The moral of the story? Scheduled tasks can make it easy to stash pages that don't change very often as static HTML files which you can then use throughout your application without worrying about your page overhead. Definitely tasty...

Posted by Daniel Short on Dec 17, 2003 at 12:00 AM | Categories: ColdFusion - VBScript -



Joshua wrote on 12/17/03 5:05 PM

Wow! Reminds me of a UNIX cron job, only better. Leaves hope for many of us stuck with .asp pages. :-0 Good find, Dan.
Daniel Short

Daniel Short wrote on 12/17/03 5:05 PM

Yep, similar to a cron job, but easier to set up and so much sexier :)

~Angela wrote on 12/17/03 11:22 PM

"but easier to set up and so much sexier :)" The ladies definitely prefer CF ;-) Thanks for getting the new feed working for DWfaq. I appreciate it :-)
Daniel Short

Daniel Short wrote on 12/17/03 11:22 PM

No problem, always fun to figure out something new.

Danilo wrote on 12/18/03 7:05 PM

You could always recdirect to a CF page if you wanted to run it. However, the scheduled task is a much better option though, since you should get it run when you want it run , and not when someone happens to acces one of your pages that can trigger your operation.
Daniel Short

Daniel Short wrote on 12/18/03 7:06 PM

Yep, on dwfaq we do cached data in a similar method, but we store the last time someting was run in an application variable, and in the global.asa file, we run a batch of commands after a set time has elapsed. Works decent, but puts the server burden on a user and isn't guaranteed to run unless someone hits the site. You can do somthing similar with scheduling if you run your own box, but it's somewhat sloppy and unreliable. CF is certainly more elegant :)

brenda wrote on 01/07/04 6:19 AM

This has nothing to do with your note, because I don't have a clue what you're talking about as you well know!! Anyway, what's up with telling us you didn't usually have snow?? That's what you get for bragging!! We could use the snow for the moisture, but I don't like temperatures down to -1!! Keep warm, love ya, hope ya'll had a nice Christmas!!