ColdFusion Scheduled Tasks
ColdFusion Scheduled Tasks enable you to schedule any ColdFusion template to run at any time. In fact, it doesn't even have to be a ColdFusion template - you can run any file, as long as its accessible via URL.
ColdFusion Scheduled Tasks makes it easy to automatically perform tasks on a regular basis. For example, you could have a task for automatically sending out email newsletters at a specific time each night.
ColdFusion Scheduled Tasks can be configured either programatically (using the
cfschedule tag)or via the ColdFusion Administrator.
Which method you use is up to you, but this choice will be made easier if you don't have access to the ColdFusion Administrator! Mind you, the
cfschedule tag (and many others) can be disabled via the ColdFusion Administrator (Sandbox Security section) so you may need to check that your server administrator hasn't disabled this tag.
Configuring ColdFusion Scheduled Tasks via the ColdFusion Administrator
Here's what the Scheduled Tasks screen looks like in the ColdFusion 2018 Administrator:
To use the ColdFusion Administrator to schedule a task:
- Log in to the ColdFusion Administrator
- Click Server Settings
- Click Scheduled Tasks
- Click Schedule New Task
- Enter a task name, choose a start date or frequency, enter the URL of the template the scheduler will run, etc. You can also click Show Additional Settings for more options.
- Once you've made the appropriate settings, click Submit Changes
Your scheduled task will now be listed on the main Scheduled Tasks page and it will run at the scheduled time.
To test your task, click the Run Scheduled Task icon (in the Action box). If you see the message This scheduled task was completed successfully. it should run at the scheduled time without any issues.
Configuring ColdFusion Scheduled Tasks using the
- Create a ColdFusion template
- Type your
cfschedulecode using the
- Save your template inside your ColdFusion application
- Run the template (i.e. open it in your browser)
Running the template will either update the ColdFusion scheduled task, or create it if it doesn't already exist. You will now see this listed in the ColdFusion Administrator under Scheduled Tasks.
Obviously, your code will be different, depending on your task and options. The full syntax allows for many other options.
Here's the syntax for the
cfschedule tag. For a more detailed explanation of this tag, see the Adobe documentation.