Skip to main content
Inspiring
September 15, 2010
Question

Check scheduled jobs programmatically

  • September 15, 2010
  • 1 reply
  • 654 views

I have inherited a nightmare application. However I can not really do much to the code itself. That is in the hands of a team of developers. I can only make it work on the huge gov't network. I have a development version I can mess around with and then make suggestions to the dev team for changes.

The problem is complex so I'll just cut to the chase. Is there a way of seeing when a scheduled job is scheduled to run? It is a one time job. Once it has run it actually recreates itself and schedules itself for the next night. Seriously, don't ask. See above paragraph for all questions about why it is done this way.

I'm thinking I will have to have a flag set or something for when the job completes. If that flag is not set, then another scheduled task will reschedule the primary task.  But being able to read the schedule would be nicer.

    This topic has been closed for replies.

    1 reply

    Charlie Arehart
    Community Expert
    Community Expert
    September 16, 2010

    It is a shame that CFSCHEDULE can still not itself let you see scheduled tasks.

    There is some code in a blog entry from Ben, but note a shorter version offered in a comment by Rahul in the thread, which I point to here:

    http://forta.com/blog/index.cfm/2006/8/28/GetScheduledTasks-Function-Returns-Scheduled-Task-List#c5B2902E2-3048-80A9-EF04942A953D2ED7

    The code in the entry itself (from Ben) also works, but as indicated in another comment, you have to mod it to add a "paused" column to the querynew function. And I just added a comment (not showing up yet) that for CF9 I also had to add "last_run" and "end_time" columns.

    But again, the simpler variant by Rahul doesn't have the issue. Both do rely on the undocumented ServiceFactory object, which won't be available if the CF Admin has turned off access to them (in the Admin "Settings" page).

    Let us know if either works for you.

    Note also that you can at least track more about what's going on with scheduled tasks by viewing the logging for it, which can be enabled in the "Logging Settings" page in the Admin.

    If either of these miss the mark on what you were seeking, sorry. Just trying to help.

    /charlie

    /Charlie (troubleshooter, carehart. org)
    DinghusAuthor
    Inspiring
    September 16, 2010

    Hmmmmm. That may be just what I need. I too wish some of this "behind the scenes" stuff was documented better.