retrieving the Scheduled Task already which exists in the CFADMIN

Gurpreet Singh Randhawa
Gurpreet Singh Randhawa used Ask the Experts™
on
I create a Cfschedule Task Progmatically, Now the Cfschedule task has been created, on the next vists, i had to run that schedular again. So just wanna check if that specific Schedular with Name exists, just use the cfschedular RUN command otherwise if it is coming first time, Create the Update for the Cfschedular which will create the schedular

1. I know it can be done through underlying serviceFactory Method, But i cannot use this because this can be blocked anytime.

2. I had seen a UDF at the CFLIB which checks for the Existing Task, but that is also checking for the XML/neo something file.

3. I like the Solution of 2nd one but can be modified like it should parse the path automatically and fetch the contents of the XML file and then parse it and find the specifc Task Name!

Well i really have no idea how to do what i asked, but u experts can guide me!

Really a Worth 500 points Answer!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
scheduled tasks are stored in neo-cron.xml which is in the \lib directory of the coldfusion program directory AFAIK, You can't really parse the path automatically as cf path parsing only works for serveable files. It is possible to get the task name though.
Most Valuable Expert 2015

Commented:
I like the Solution of 2nd one but can be modified like it should parse the path automatically and fetch the contents of the XML file and then parse it and find the specifc Task Name!

The IsScheduledTask function already does all that. So I'm not sure what you're asking ?

Though if you're on a shared host, they may not allow you access to the XML files either
Most Valuable Expert 2015

Commented:
if that specific Schedular with Name exists, just use the cfschedular RUN command otherwise if it is coming first time, Create the Update for the Cfschedular


You don't need a special function for that. Just RUN the task. CF will tell you if it doesn't exist! A cftry / cfcatch should be all you need.

<cftry>
       <cfschedule action="run" task="A task that doesn't exist">  
    <cfcatch>
         task doesn't exist. update/create it with <cfschedule ...>
    </cfcatch>
</cftry>
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

@agx, i think your point is valid as we can wrap around try catch and if will through an error and catch will create the schedular

Hmm! seems valid to me but needs more clarification
Most Valuable Expert 2015

Commented:
Hmm! seems valid to me but needs more clarification
No, it really is that simple. What is your question?
my question was that my servers do bounce every few days and schedulled tasks gets cleared off! also wanna make such a secure way that it should ho for some internal undocumeneted or restricted way to check the file and run the scheduleer
Most Valuable Expert 2015

Commented:
do bounce every few days and schedulled tasks gets cleared off!

What does "cleared off" mean? Scheduled tasks exists until _you_ delete them.  

make such a secure way that it should ho for some internal undocumeneted or restricted way to check the file and run the scheduleer

It's not clear what you're asking.  Could you rephrase that?
i mean to say currently i am using the ServiceFactory Java Method which may be blocked!

second i do not want to use the method which calls its neoxml file
Most Valuable Expert 2015
Commented:
Ok. Then like I said, your only option is to use cftry/cfcatch.
 
<cftry>
       <cfschedule action="run" task="A task that doesn't exist">  
    <cfcatch>
         task doesn't exist. update/create it with <cfschedule ...>
    </cfcatch>
</cftry>

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial