Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do scheduled tasks load Application.cfc in the same way as web pages?

Do scheduled tasks load the Application.cfc in the same way as web pages? We have a task which runs nightly and needs to use a services cfc loaded into the application. Will the application scope exist in the same way as it does when calling a standard web page? Are there any differences or gotchas to watch out for?

like image 474
Nick Van Brunt Avatar asked Mar 03 '10 15:03

Nick Van Brunt


People also ask

How do scheduled tasks work?

The Task Scheduler enables you to automatically perform routine tasks on a chosen computer. Task Scheduler does this by monitoring whatever criteria you choose (referred to as triggers) and then executing the tasks when those criteria are met.

How are scheduled tasks implemented?

Open Start, Search for "Task Scheduler" and press enter to open "Task Scheduler". Right-click on the "Task Scheduler Library" and click on the "New Folder" option. Enter the name of the New folder and click on the "OK" button. Navigate the following: Task Scheduler Library > New Folder, then click on "Create Task".

Where are schedule tasks stored?

There are two different folders labeled "tasks". The first folder is relative to the scheduled tasks that would appear in the task scheduler, these are in c:\windows\tasks. The second tasks folder is located in c:\windows\system32\tasks.

How do I run a scheduled task as a local system?

In the Task Scheduler window click "Create Task" on the right hand bar under the "Actions" pane. In the "Create Task" dialog click the "Change User or Group" button. Make sure "From this location" is set to the local machine name (to change click "Locations" button and select the local computer name)


1 Answers

The CF task scheduler makes an HTTP call to the URL you specify in the task, so all standard rules apply. Application.cfm/application.cfc is run, the app scope exists, and so forth.

The only thing, offhand, you need to keep in mind is that the scheduler itself doesn't recognize errors, so you should write the task in such a way that it logs, emails, etc. on error. And, during testing, probably on success.

Edit: Sergii noted something I'd overlooked. The scheduler doesn't maintain cookies. It acts more like a spider. Therefore, anything in the session or client scopes or written to cookies won't actually be stored, and will be lost next time the action is run.

like image 162
Ben Doom Avatar answered Sep 28 '22 21:09

Ben Doom