cfschedule
Description
Provides a programmatic interface to the ColdFusion 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.
Categories
Related
History
ColdFusion
MX 6.1: Changed the way intervals are calculated. The day length now
reflects changes between standard and daylight saving times. The
month length is now the calendar month length, not four weeks. The
scheduler handles leap years correctly.
Syntax
<cfschedule
action = "run|update|pause|resume|delete"
task = "task name"
endDate = "date"
endTime = "time"
file = "filename"
interval = "seconds"
operation = "HTTPRequest"
password = "password"
path = "path to file"
port = "port number"
proxyPassword = "password"
proxyPort = "port number"
proxyServer = "host name"
proxyUser = "user name"
publish = "yes|no"
requestTimeOut = "seconds"
resolveURL = "yes|no"
startDate = "date"
startTime = "time"
url = "URL"
username = "user name">
OR
<cfschedule
action = "delete"
task = "task name">
OR
<cfschedule
action = "run"
task = "task name">
Note: You
can specify this tag's attributes in an attributeCollection attribute
whose value is a structure. Specify the structure name in the attributeCollection attribute
and use the tag’s attribute names as structure keys.
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| action | delete: deletes the specified task. update: updates an existing task or creates a 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. | Required | |
| endDate | Date when scheduled task ends. | Optional | |
| endTime | Time when scheduled task ends (seconds). | Optional | |
| file | Name of the file in which to store the published output of the scheduled task. | Required if publish="Yes" | |
| interval | Interval at which task is scheduled: number of seconds once daily weekly monthly | Required if action="update" | |
| operation | Operation that the scheduler performs. Must be HTTPRequest. | Required if action="update" | |
| password | Password, if URL is protected. | Optional | |
| path | Path to the directory in which to put the published file. | Required if publish = "Yes" | |
| port | 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. | Optional | 80 |
| proxyPassword | Password to provide to the proxy server. | Opt | |
| proxyPort | Port number to use on the proxy server. | Optional | 80 |
| proxyServer | Host name or IP address of a proxy server. | Optional | |
| proxyUser | User name to provide to the proxy server. | Opt | |
| publish | yes: saves the result to a file. no | Optional | no |
| requestTimeOut | Can be used to extend the default time-out period. | Optional | |
| resolveURL | yes: resolves links in the output page to absolute references. no | Optional | no |
| startDate | Date on which to first run the scheduled task. | Required if action="update" | |
| startTime | Time at which to run the scheduled of task starts. | Required if action="update" | |
| task | Name of the task. | Required | |
| url | URL of the page to execute. | Required if action="update" | |
| username | User name, if URL is protected. | Optional |
Usage
This tag and the ColdFusion Administrator Scheduled task page schedule ColdFusion tasks. Tasks that you add or change using this tag are visible in the Administrator. You can disable this tag in the Administrator Sandbox/Resource security page. This tag’s success or failure status is written to the schedule.log file in the cf_root/logs directory (cf_webapp_root/WEB-INF/cfusion/logs in the multiserver and J2EE configurations).
When you create a task, you specify the URL of the ColdFusion page to execute, the date, time and frequency of execution, and whether to publish the task output to an HTML file. If the output is published, you specify the output file path and file.
If you schedule a job to run monthly on any date in the range 28-31, the scheduler does the following:
If you schedule a monthly job to run on the last day of a month, the scheduled job will run on the last day of each month. For example, if you schedule a monthly job to start on January 31, it will run on January 31, February 28 or 29, March 31, April 30, and so on.
If you schedule a monthly job to run on the 29th or 30th of the month, the job will run on the specified day of each month for 30 or 31-day months, and the last day of February. For example, if you schedule a monthly job to start on January 30, the job will run on January 30, February 28 or 29, March 30, April 30, and so on.
If you schedule a job to run once, the starting time is in the past, and the task has not yet run, it runs immediately. If you schedule a recurring job with a start time in the past, ColdFusion schedules the job to run on the next closest interval in the future.
The Scheduler configuration file, cf_root\lib\neo-cron.xml contains all scheduled events, as individual entries.
When you create a task, you specify the URL of the ColdFusion page to execute, the date, time and frequency of execution, and whether to publish the task output to an HTML file. If the output is published, you specify the output file path and file.
If you schedule a job to run monthly on any date in the range 28-31, the scheduler does the following:
If you schedule a monthly job to run on the last day of a month, the scheduled job will run on the last day of each month. For example, if you schedule a monthly job to start on January 31, it will run on January 31, February 28 or 29, March 31, April 30, and so on.
If you schedule a monthly job to run on the 29th or 30th of the month, the job will run on the specified day of each month for 30 or 31-day months, and the last day of February. For example, if you schedule a monthly job to start on January 30, the job will run on January 30, February 28 or 29, March 30, April 30, and so on.
If you schedule a job to run once, the starting time is in the past, and the task has not yet run, it runs immediately. If you schedule a recurring job with a start time in the past, ColdFusion schedules the job to run on the next closest interval in the future.
The Scheduler configuration file, cf_root\lib\neo-cron.xml contains all scheduled events, as individual entries.
Example
<h3>cfschedule Example</h3>
<!--- This read-only example schedules a task.
To run the example, remove the comments around the code
and change the startDate, startTime, url, file, and path attributes
to appropriate values. --->
<!---
<cfschedule action = "update"
task = "TaskName"
operation = "HTTPRequest"
url = "http://127.0.0.1/playpen/history.cfm"
startDate = "8/7/03"
startTime = "12:25 PM"
interval = "3600"
resolveURL = "Yes"
publish = "Yes"
file = "sample.html"
path = "c:\inetpub\wwwroot\playpen"
requestTimeOut = "600">
--->