Coldfusion: Detecting if being run by the scheduler

别来无恙 提交于 2019-12-14 03:39:34

问题


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);


回答1:


Check for the user agent. The user agent is "CFSCHEDULE" but please confirm this first.




回答2:


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)




回答3:


I am not sure but if application run through scheduler then cgi.remote_address must be same for all request that you can track.....and mark "isSchedule"....




回答4:


It's a common practice to let the task scheduler run a list of tasks which in tern trigger the actual tasks. I.e. you ran "dailytask.cfm which cfincludes the task that you want to run. You can now add url.parameters or other things to it to identify the source of the trigger.



来源:https://stackoverflow.com/questions/6790834/coldfusion-detecting-if-being-run-by-the-scheduler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!