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="");

Attribute Reference for the cfschedule tag

action

Required: Yes
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

Required: Yes
Name of the task.

operation

Required: No
Operation that the scheduler performs. Must be HTTPRequest.

file

Required: No
Name of the file in which to store the published output of
the scheuled task

path

Required: No
Path to the directory in which to put the published file.

startdate

Required: No
Date on which to first run the scheuled task.

starttime

Required: No
Time at which to run the scheduled of task starts.

URL

Required: No
URL of the page to execute.

port

Required: No
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

Required: No
Default: NO
Yes: save the result to a file
No: does not

endDate

Required: No
Date when scheduled task ends.

endTime

Required: No
Time when scheduled task ends (seconds).

interval

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

requesttimeout

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

username

Required: No
Username, if URL is protected.

password

Required: No
Password, if URL is protected.

proxyserver

Required: No
Host name or IP address of a proxy server.

proxyport

Required: No
Default: 80
Port number to use on the proxy server.

proxyuser

Required: No
User name to provide to the proxy server.

proxypassword

Required: No
Password to provide to the proxy server.

resolveurl

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

group

Required: No
Default: default
The group to which the scheduled task belongs.

mode

Required: No
Default: server
If the task is server-specific or application specific.

result (coldfusion)/returnvariable (lucee)

Required: For the list action
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