Is there a way for a ColdFusion app to know whether it is being run from the scheduler vs. from a browser? Ideally, I'd like to set a Session flag, for instance "isScheduled" in Application.cfm to be used throughout the app.
EDIT I ended up checking the user agent, and that it is being run locally (to improve security), and (since it is running in Application.cfm) that the page is in the folder which allows scheduling:
Request.isScheduled = FindNoCase("CFSCHEDULE",CGI.HTTP_USER_AGENT)
and (Find("10.",CGI.REMOTE_ADDR)==1
or Find("198.162.",CGI.REMOTE_ADDR)==1)
and FindNoCase("scheduled",CGI.CF_TEMPLATE_PATH);
Right-click the Task Scheduler service, and then click Properties. On the General tab, make sure that the startup type is set to automatic, and that the service status is Started. If the service is not running, click Start.
Scheduler for PCF is a service for scheduling the execution of Diego tasks, such as database migrations, emails, or batch jobs, as well as the execution of outbound HTTP calls. Scheduler for PCF enables developers to do the following: Create, run, and schedule jobs and view job history.
Check for the user agent. The user agent is "CFSCHEDULE" but please confirm this first.
I nest my Application.cfm logic in a cfif, that checks to see if a parameter ('cron') is defined. If it is, then it skips all of the rest of the logic in Application like authentication, header crap, etc.
Then when I set up the scheduled tasks I pass in the URL I want to hit with the cron parameter (http://mysite.com/scheduledtasks.cfm?cron=yo)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With