Skip to main content
Participant
January 15, 2010
Question

cfschedule pause before launch ?

  • January 15, 2010
  • 1 reply
  • 578 views

Hi,

At the moment, I'm working on a project where we want to save scheduled tasks in an autoConfig file, launched at each reboot of the server.

That allows developers to add scheduled tasks without creating them through the CF Admin console.


We can create the tasks with the code :

<cfschedule

                action = "update"

                task = "taskName"

                operation = "HTTPRequest"

                startDate = "Jan 01, 2010"

                startTime = "08:00"

                url = "http://website/batchName.cfm"

                interval = "Weekly"

                username = "admin"

                password = "admin">

If we add a cfschedule tag with "pause" action after this one, the tasks will run because the date is in the past.

Do you have any idea how to schedule a weekly task without launch at creation ?

Thanks for your help.

David.

    This topic has been closed for replies.

    1 reply

    Owainnorth
    Inspiring
    January 15, 2010

    Personally, I wouldn't store the start dates in the ini file for this very reason. I don't know what format your autoconfig file is, but let's pretend it's XML just because that's fun:


    <autoconfig>
      <schedtasks>
        <task>
          <name>My Task 1</name>
          <operation>HTTPRequest</operation>
          <url>http://mywebsite.com</url>
          <recurrence>WEEKLY</recurrence>
          <runday>WED</runday>
          <runtime>13:00</runtime>
          <enddate></enddate>
        </task>
        <task>
          <name>My Task 2</name>
          <operation>HTTPRequest</operation>
          <url>http://mywebsite.com/other</url>
          <recurrence>DAILY</recurrence>
          <runday></runday>
          <runtime>14:00</runtime>
          <enddate>17-JAN-2010</enddate>
        </task>
      </schedtasks>
    </autoconfig>

    Then in your Application.cfc create a function that reads the XML and then programatically establishes the start date. You've then got complete flow control over if it's daily, has the start time passed? If so, start from tomorrow. If it's weekly, figure out the start date from the run day, etc etc.

    This way you don't have to worry about dates at all (except end dates, if relevant) and the minimum amount of data is required in your config file. Less data written by other people = less to go wrong

    stuuserAuthor
    Participant
    January 15, 2010

    Hi and thanks for your answer.


    Actually, the autoConfig file is written in coldfusion (classic CFM), and launch at start through the Application.cfc.

    I'm going to look forward to develop your proposal as soon as possible.