cfschedule

Provides a programmatic interface to the CFML scheduling
engine. Can run a CFML page at scheduled intervals, with the
option to write the page output to a static HTML page. This
feature enables you to schedule pages that publish data, such
as reports, without waiting while a database transaction is
performed to populate the page.

 <cfschedule action="delete" task="">

 cfschedule(action="delete", task="");

cfschedule Attribute Reference

action String
Required

delete: deletes the specified task
update: updates an existing task or creates a new task,
if one with the name specified by the task attribute
does not exist
run: executes the specified task
pause: Pauses the specified task.
resume: Continues executing the specified task.
list: Lists all the scheduled tasks.
Values:
  • delete
  • update
  • run
  • pause
  • resume
  • list

task String
Required

Name of the task.

operation String

Operation that the scheduler performs. Must be HTTPRequest.

file String

Name of the file in which to store the published output of
the scheduled task

path String

Path to the directory in which to put the published file.

startdate String

Date on which to first run the scheduled task.

starttime String

Time at which to run the scheduled of task starts.

URL URL

URL of the page to execute.

port Numeric
Default: 80

Port to use on the server that is specified by the url
parameter. If resolveURL = "yes", retrieved document URLs
that specify a port number are automatically resolved, to
preserve links in the retrieved document. A port value in
the url attribute overrides this value.

publish boolean
Default: NO

Yes: save the result to a file
No: does not

endDate String

Date when scheduled task ends.

endTime Numeric

Time when scheduled task ends (seconds).

interval String

Interval at which task is scheduled.
* number of seconds (minimum is 60)
* once
* daily
* weekly
* monthly
Values:
  • once
  • daily
  • weekly
  • monthly

requesttimeout Numeric

Deprecated as of CF 11+ used to extend the default timeout period.

username String

Username, if URL is protected.

password String

Password, if URL is protected.

proxyserver String

Host name or IP address of a proxy server.

proxyport Numeric
Default: 80

Port number to use on the proxy server.

proxyuser String

User name to provide to the proxy server.

proxypassword String

Password to provide to the proxy server.

resolveurl boolean
Default: NO

Yes: resolve links in the output page to absolute
references
No: does not

group String
Default: default

The group to which the scheduled task belongs.

mode String
Default: server

If the task is server-specific or application specific.

result (coldfusion)/returnvariable (lucee) Query

Name for the query in which cfschedule returns the result variables.

Examples sample code using the cfschedule tag


Create or update a task

Tell Coldfusion to run 'importData.cfm' daily at 7AM

<cfschedule
 action="update"
 task="importMyCSVFileToDB"
 operation="HTTPRequest"
 startDate="5/12/2016"
 startTime="7:00 AM"
 url="http://www.mydomain.com/scheduled/importData.cfm"
 interval="daily" />

Delete a scheduled task

Delete the task 'importMyCSVFileToDB' from the list of Coldfusion scheduled jobs

<cfschedule
 action="delete"
 task="importMyCSVFileToDB" />

Fork me on GitHub