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:

ColdFusion Scheduled Tasks Screenshot

To use the ColdFusion Administrator to schedule a task:

  1. Log in to the ColdFusion Administrator
  2. Click Server Settings
  3. Click Scheduled Tasks
  4. Click Schedule New Task
  5. 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.
  6. 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 cfschedule tag

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.

Here's a cfschedule example:

Obviously, your code will be different, depending on your task and options. The full syntax allows for many other options.

The cfschedule Syntax

Here's the syntax for the cfschedule tag. For a more detailed explanation of this tag, see the Adobe documentation.