Skip to main content
Participant
October 1, 2009
Answered

Call Multiple Files From Single ColdFusion Scheduled Task

  • October 1, 2009
  • 1 reply
  • 822 views


Our host only allows us to have 5 scheduled tasks per account but we need to run cfml applications to import data for multiple sites (at least 15 processes).  What I'd like to do is combine all the 'sample requests' for all sites into ONE scheduled task that will run them one after another thus cutting back on the number of scheduled tasks needed.

We're using ColdFusion to connect to a MySQL DB to gather all sample requests. First the app retrieves all the unflagged records from a remote db then begins looping through all the returned records. On the each loop, the app 'scrubs' the data by properly formatting phone numbers, fixing address abbreviations, etc. Next the app saves the scrubbed data to a local MS SQL table then starts the loop over on the next row. Lastly the app sends out an email saying it has completed successfully.

What I'm trying to do is Create a New Parent App that will run as a scheduled task to do the following:
- New Parent App Runs as Scheduled Task and calls/includes first of X sample request app files
- New Parent App runs first sample request app as described above (which can take up to a minute to process)
- Parent app waits until after first sample request app completes, then Parent App goes on to second sample request app, etc.
- After all sample requests are complete New App sends completion email with date and time

The problem I'm having is getting the scheduled task to wait for apppage1.cfm to finish before loading apppage2.cfm and so on. Can you give me a simple codeset that accomplishes this?

I've attached a sample of the include page the needs to complete before moving on!

    This topic has been closed for replies.
    Correct answer Dan_Bracuk

    Our approach is a bit more comprehensive.

    First, we (meaning my co-workers) wrote a custom tag that does something like this:

    <cftry>

    <cfinclude the template>

    <cfcatch>

    log any errors

    Then our actual scheduled job go like this:

    set a really long timeout (and none of the actual jobs can have their own timeout)

    set some variables

    use the custom tag for each job we want to run

    send mail if any errors occurred.

    1 reply

    Dan_BracukCorrect answer
    Inspiring
    October 1, 2009

    Our approach is a bit more comprehensive.

    First, we (meaning my co-workers) wrote a custom tag that does something like this:

    <cftry>

    <cfinclude the template>

    <cfcatch>

    log any errors

    Then our actual scheduled job go like this:

    set a really long timeout (and none of the actual jobs can have their own timeout)

    set some variables

    use the custom tag for each job we want to run

    send mail if any errors occurred.

    ilssac
    Inspiring
    October 1, 2009

    Just as another thought exercise.

    A scheduled task is simple an HTTP request of an CFMIL file.

    A <cfhttp...> tag is a simple request of a file which can include CFML files.

    I would think it would be trivial to create a loop or series of <cfhttp...> tags in a single cfml file that would be called as a scheduled task that would then span as many other http requests as desired.

    But Dan's solution is probably more complete.

    covareoAuthor
    Participant
    October 3, 2009

    So simple its genius! Thanks for the suggestion