I had a hosting provider recently ask me if there was a way to automatically remove disabled or expired scheduled tasks without having to go through the ColdFusion administrator, because he had many servers and each server had many scheduled tasks so it would have been a pretty large chore to maintain this manually.
ColdFusion scheduled task information is stored as WDDX in the file cfusionmx7lib
eo-cron.xml
Below is the script I created that will cleanup the neo-cron.xml.
I would suggest that you create a back up of your neo-cron.xml file before you start using this, just in case.
<!--- Read the current neo-cron file --->
<cffile action="READ"
file="c:cfusionmx7lib
eo-cron.xml"
variable="neocronwddx">
<!--- convert the wddx to a coldfusion structure --->
<cfwddx action="WDDX2CFML" input="#neocronwddx#" output="neocron">
<!--- dump current neo-cron --->
<cfdump var="#neocron#">
<!--- loop through the structure and remove disabled or expired entries --->
<cfloop collection="#neocron[1]#" item="i">
<cfif neocron[1][i].disabled eq "YES"
or (structkeyexists(neocron[1][i],"end_date")
and datecompare(neocron[1][i].end_date,now()) eq -1)>
<cfset structdelete(neocron[1],i)>
</cfif>
</cfloop>
<!--- dump updated neo-cron --->
<cfdump var="#neocron#">
<!--- convert the structure to wddx --->
<cfwddx action="CFML2WDDX" input="#neocron#" output="neocronwddx">
<!--- save the new neo-cron file --->
<cffile action="write"
file="c:cfusionmx7lib
eo-cron.xml"
output="#neocronwddx#"
addnewline="No"
nameconflict="OVERWRITE">
Additionally, I would recommend that you put named cflocks around the process to protect the integrity of the file, and incorporate adequate error handling to ensure a corrupt version of the neo-cron.xml file does not get saved.
Lastly, to re-emphasize a point I made in entry, any time you write code to edit any system file, you will want to make sure you have a back up of the original file in the event you mess it up.
<cffile action="read" file="#server.coldfusion.rootdir#lib
eo-cron.xml" variable="wddxNeocron">
<cfwddx action="WDDX2CFML" input="#wddxNeocron#" output="sctNeocron">
<cfset theTarget = "timeMonitor">
<cfset theInterval = "">
<cfoutput>
<cfloop collection="#sctNeocron[1]#" item="i">
#i# #sctNeocron[1][i].interval#<br/>
<cfif i eq theTarget>
<cfset theInterval = sctNeocron[1][i].interval>
</cfif>
</cfloop>