#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    Sydney, AU
    Posts
    37
    Rep Power
    12

    Question Scheduling tasks in cold fusion


    We have a web site that uses cold fusion and SQL server 2000.
    I'm looking to schedule some tasks and send automatic emails, but I'm not aware of how to do this. An example of what I want to do:
    1. check the database every week to see if some user has not logged in.
    2. send him an email.

    How can I automate this entire chore so I don't need to do it manually every week?

    Thanks.
    We can help export your products http://www.GIAgroup.com/
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,281
    Rep Power
    968
    You can create scheduled tasks through the ColdFusion administrator interface. Just point it to a CF file or executable, tell it when you want it to run, and it'll run it at that time. You can also do this programmatcally with the
    <cfschedule> tag.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    Sydney, AU
    Posts
    37
    Rep Power
    12

    Thumbs up


    Thanks kiteless. You've been a wonderful help once again!
    No one else seems to answer my questions... hehe
    We can help export your products http://www.GIAgroup.com/
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    Sydney, AU
    Posts
    37
    Rep Power
    12

    Post


    Follow up.........

    Using the CF admin interface, i schedule a task and it seems to work the first time. But i told it to redo the task every 10 min and it doesnt do it. I waited half an hour... the settings for task refresh is at 10 min too. The page is working fine because it works the first time i tell the task to run.

    Any suggestions what's the problem?
    We can help export your products http://www.GIAgroup.com/
  8. #5
  9. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,281
    Rep Power
    968
    What version of CF are you on? Have you set the start and end times for your task? I think these are required. If you want it to fire every 10 minutes all day, you probably want something like: start at 00:10 (10 after midnight) and finishing at 23:50 (10 til midnight).
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    Sydney, AU
    Posts
    37
    Rep Power
    12
    I'm using CF 5.

    The settings I have used are:
    Daily every 10 minutes from 12:00:00 to 15:00:00

    This is just for testing. However, it doesn't seem to function. It only runs once when I press Go on the admin interface.
    We can help export your products http://www.GIAgroup.com/
  12. #7
  13. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,281
    Rep Power
    968
    Well when you test it, is it between 12:00 and 15:00? Also, are *all* of the CF services running? I believe that all the services must be running for the scheduled tasks to fire.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    Sydney, AU
    Posts
    37
    Rep Power
    12
    Yes, I am testing between those times that I've set.
    Well, how do I check to see if all CF services are running?
    We can help export your products http://www.GIAgroup.com/
  16. #9
  17. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,281
    Rep Power
    968
    On Windows you look in the services applet. Not sure how to do this on Unix/Linux but the need to check that everything is running is just as urgent.
  18. #10
  19. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,281
    Rep Power
    968
    Also, do you have access to the Scheduler.log file? If so, does it have any info to help diagnose the problem?
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    Sydney, AU
    Posts
    37
    Rep Power
    12
    kiteless, all the cold fusion services seem to be running..
    as for the log file, no information in there... only those tasks which were successfully run (i.e. when i pressed go) were logged in there.

    also, i thought maybe its a date conflict. we using the dd/mm/yyyy but then i changed the start date to 01/01/2004 and to end on 04/04/2004 and it still didn't send after ten minutes... in fact waited for 25 min. i'm stumped!
    We can help export your products http://www.GIAgroup.com/
  22. #12
  23. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,281
    Rep Power
    968
    Just for fun, did you try creating the same scheduled task programmatically using the <cfschedule> tag?
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    Sydney, AU
    Posts
    37
    Rep Power
    12

    Question


    kiteless, sorry about the late late reply, been busy with other things..

    Now how do I go about creating the cfschedule and where? I presume it just needs to run the whole cfschedule tag once and that's it... it should do its thing at intervals until the end date that I specify in the tag.
    We can help export your products http://www.GIAgroup.com/
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    1
    Rep Power
    0

    CFScheduler timer


    In the CFSchedule, you can set how often CFSchedule will trigger. It defaults to 15 minutes, so that means that if you set the schedule for 10 minutes in the future, it will not fire because the trigger will never be reached.
    So, if you want the schedule to fire, you need to either set the schedule to be greater than 15 minutes, or set the trigger to less than your schedule. In this case, since you want to fire in 10 minutes, set the trigger for every 5 minutes...
    But bear in mind that if you have a slow server, or you have a lot of processes on the server, setting the trigger to every 5 minutes may put a strain on your machine...
    Your call
    Ed
    web/gadget guru
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    1
    Rep Power
    0
    I have a problem with setting times. I want set the schedule from tonight to tomorrow morning.

    My cfschedule is like this:
    startdate="26/3/2004" starttime="22:00:00" endddate="27/3/2004" endtime="3:00:00"

    But I get the following error:
    Invalid Parameters have been passed to the scheduling service Parameter {ts '1899-12-30 22:00:00'} should earlier than parameter {ts '1899-12-30 03:00:00'}

    It seems to be comparing only times, not dates. I have no problem when I put endtime later than starttime.

    Does anyone know how to handle this?

IMN logo majestic logo threadwatch logo seochat tools logo