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

Name of the task.

operation

Operation that the scheduler performs. Must be HTTPRequest.

file

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

path

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

startdate

Date on which to first run the scheduled task.

starttime

Time at which to run the scheduled of task starts.

URL

URL of the page to execute.

port
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
Default: NO

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

endDate

Date when scheduled task ends.

endTime

Time when scheduled task ends (seconds).

interval

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

requesttimeout

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

username

Username, if URL is protected.

password

Password, if URL is protected.

proxyserver

Host name or IP address of a proxy server.

proxyport
Default: 80

Port number to use on the proxy server.

proxyuser

User name to provide to the proxy server.

proxypassword

Password to provide to the proxy server.

resolveurl
Default: NO

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

group
Default: default

The group to which the scheduled task belongs.

mode
Default: server

If the task is server-specific or application specific.

result (coldfusion)/returnvariable (lucee)

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