House of Fusion
Home of the ColdFusion Community

Search cf-talk

December 02, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31       

Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

Best way to cause scheduled tasks to run consecutively?

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
05/24/2008 08:34 PM

Hi, all... Yes, I'm having to work this Memorial Day weekend to meet some deadlines. I need to set up a series of scheduled tasks and insure that they run consecutively.  In other words, I need to make sure that each one completes before the next one starts. What's the best approach for that? I hesitate to put all the tasks (a series of queries, actually) in one large file, preferring to let the server run separate tasks...but perhaps with a pause routine in between the queries it wouldn't matter? Thanks for any advice. Rick

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mike Kear
05/24/2008 09:48 PM

G'day Rick, There are two ways I could think of to do it [A]  make one task,  that in turn calls all the others, one after the other.  Perhaps with some logic in each to ensure the previous task completed successfully, if that's appropriate. [B] give each task an identical interval, but long enough to allow all teh others to run with a space for safety's sake, and starting at staggered times.    e.g.: task 1, every 5 minutes, starting at 10am task 2, every 5 minutes starting at 10:02am task 3, every 5 minutes, starting at 10:03am task 4, every 5 minutes, starting at 10:06am  etc. The start time would be based on teh average length of time the previous task runs, plus a margin to ensure the task starts after the previous one is finished. Of the two, I prefer [A].       The other method relies on everything happening properly and if something goes wrong, your sequence will go haywire. Cheers Mike Kear Windsor, NSW, Australia Adobe Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month On Sun, May 25, 2008 at 10:33 AM, Rick Faircloth <Rick@whitestonemedia.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mary Jo Sminkey
05/24/2008 10:07 PM

>[A]  make one task,  that in turn calls all the others, one after the >other.  Perhaps with some logic in each to ensure the previous task >completed successfully, if that's appropriate. I would go with A as well. Be sure to also consider what needs to happen if for any reason something happens to halt processing in the middle, like a server reboot, and whether you need some kind of rollback or running counter for which tasks have been completed in the event of something like that happening. MJS

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
05/24/2008 11:12 PM

Thanks, Mike and Mary Jo... Questions: I'm not able to think of how to code a task to "call" another... nothing's coming to mind.  How would I accomplish that? Also, the logic to insure a previous task completed... such as a variable that is set to "true" or something like that? And, Mary Jo, concerning rollback...would cftransaction be appropriate? The  processes aren't dependent upon one another, they are just long-running and rather processor intensive so I don't want any concurrent tasks running. If I were to put all tasks into one long file and put them into a single named thread, would that be a good approach?  Problems with that? Thanks for the suggestions! Rick ----- Excess quoted text cut - see Original Post for more ----- something > happens to halt processing in the middle, like a server reboot, and whether you need some kind of > rollback or running counter for which tasks have been completed in the event of something like that > happening. > > MJS > >

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mary Jo Sminkey
05/24/2008 11:38 PM

> The  processes aren't dependent upon one another, they are just > long-running > and rather processor intensive so I don't want any concurrent tasks > running. Ah, well in that case B would probably work fine. I was assuming they were dependent. You certainly wouldn't want to put a bunch of independent queries into a cftransaction. I was thinking more along the lines of if Task A has run and then Task B gets interrupted for whatever reason (let's say the server locked up during the task, ran out of memory, whatever) when it was rebooted do you have to keep track of the fact that you were on Task B, i.e. is it important that you start where you left off? If that isn't an issue, and it doesn't sound like it is, you are probably fine just setting up the tasks to run at specific intervals. What you might want to do is just grab the tickcount when they run and monitor how long they are taking, especially if the data will be growing over time. --- Mary Jo

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
rex
05/25/2008 12:13 AM

Since a CF Scheduled task is basically just a call to a webpage, just put a <CFLOCATION> in your code. So, your scheduled task will be calling task1.cfm, and the last part of your code would be a <CFLOCATION URL=" task2.cfm" /> If you are only doing queries, the best way to do it would be on the SQL side.  A stored procedure as a SQL job would be the way to go.  That way, you can wrap everything around a transaction and rollback when it breaks.  It'll be faster, plus if you use a CF Scheduled Task, you will be breaking out your queries and you cannot do CFTRANSACTIONs. And, yes, even though you can still do regular transactions, bear in mind that if your CF errors out with open transactions you will run into locking issues.  Doing this on the database side is the best way to approach this. Rick Faircloth wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
05/25/2008 08:42 AM

Thanks, Rex and Mary Jo... I figured the call would be something rather obvious, but didn't want to make any assumptions without getting input. This will be my *first* opportunity to work with a stored procedure. Well, not opportunity, but situation where it's really called for. I'll do some digging in the MySQL 5 docs on that and see what I can do. Thanks, again! Rick ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Claude Schneegans
05/25/2008 09:09 AM

>>What's the best approach for that? Have each task schedule the next one at the end of its precess.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
05/25/2008 10:07 AM

> Have each task schedule the next one at the end of its precess. That's a good approach to look into... (and much simpler than trying to understand and implement stored procedures when I'm under and extremely tight deadline! :o) I like the idea of rolling a specific query back if it fails part way through.  These queries are simply transferring data from temp tables to production tables each day.  If a query should only transfer part of the data, I'd like to remove all data that that particular query was handling from the table and run it later, or perhaps just restart the query. Would cftransaction be advisable for this? Thanks, Claude... Rick >  >>What's the best approach for that? > > Have each task schedule the next one at the end of its precess. > >

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dana Kowalski
05/26/2008 12:39 PM

One thing to note about manually calling files that you wanted to be scheduled tasks.... If you do things this way then the admin logging of scheduled tasks will no longer record the information you may have wanted it to. Just a consideration to keep in mind. If the task itself does any kind of logging I suppose this would be redundant, however I point it out as I didn't see it mentioned.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
05/26/2008 01:58 PM

Thanks for the info, Dana! Definitely something to keep in mind... Rick > One thing to note about manually calling files that you wanted to be scheduled tasks.... If you do > things this way then the admin logging of scheduled tasks will no longer record the information you may > have wanted it to. Just a consideration to keep in mind. If the task itself does any kind of logging I > suppose this would be redundant, however I point it out as I didn't see it mentioned. >


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists