Skip to content

Instantly share code, notes, and snippets.

@cflove
Last active June 27, 2022 16:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cflove/5255391 to your computer and use it in GitHub Desktop.
Save cflove/5255391 to your computer and use it in GitHub Desktop.
Import ColdFusion schedules from a server
<cfset sf = createobject('Java','coldfusion.server.ServiceFactory')>
<cfset tasks = sf.CronService.listAll()/>
<cfloop from="1" to="#arraylen(tasks)#" index="i">
<cfset here.task = tasks[i]>
<cfoutput>
<pre>
&lt;cfschedule
action = "update"
task = "#here.task.task#"
<cfif StructKeyExists(here.task,'end_date')>endDate = "#here.task.end_date#"</cfif>
<cfif StructKeyExists(here.task,'end_time')>endTime = "#here.task.end_time#"</cfif>
<cfif StructKeyExists(here.task,'file') and len(here.task.file)>file = "#here.task.file#"</cfif>
<cfif StructKeyExists(here.task,'interval')>interval = "#here.task.interval#"</cfif>
operation = "HTTPRequest"
<cfif StructKeyExists(here.task,'password') and len(here.task.password)>password = "#here.task.password#"</cfif>
<cfif StructKeyExists(here.task,'path')>path = "#here.task.path#"</cfif>
<cfif StructKeyExists(here.task,'http_port') and val(here.task.http_port) neq 80>port = "#here.task.http_port#"</cfif>
<cfif StructKeyExists(here.task,'http_proxy_port') and val(here.task.http_proxy_port) neq 80>proxyPort = "#here.task.http_proxy_port#"</cfif>
<cfif StructKeyExists(here.task,'proxy_server') and len(here.task.proxy_server)>proxyServer = "#here.task.proxy_server#"</cfif>
<cfif StructKeyExists(here.task,'file') and len(here.task.file)>publish = "yes"</cfif>
<cfif StructKeyExists(here.task,'request_time_out') and len(here.task.request_time_out)>requestTimeOut = "#here.task.request_time_out#"</cfif>
<cfif StructKeyExists(here.task,'resolveurl')>resolveURL = "#YesNoFormat(here.task.resolveurl)#"</cfif>
<cfif StructKeyExists(here.task,'start_date')>startDate = "#here.task.start_date#"</cfif>
<cfif StructKeyExists(here.task,'start_time')>startTime = "#here.task.start_time#"</cfif>
<cfif StructKeyExists(here.task,'url')>url = "#here.task.url#"</cfif>
<cfif StructKeyExists(here.task,'username') and len(here.task.username)>username = "#here.task.username#"</cfif>&gt;
</pre>
</cfoutput>
</cfloop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment