Search code examples
coldfusionscheduled-tasksrailocfml

How to detect if a script is running via a scheduled task


Is there a way to detect if a script is runned by a scheduled task.

I have a script which gives throws a ClientAbortException because I am using cfflush. I need to detect if the script is running via a scheduled task so the script can run successfully.


Solution

  • It seems that you can check it via CGI.HTTP_USER_AGENT:

    <cfif CGI.HTTP_USER_AGENT NEQ "CFSCHEDULE">
      <cfflush>
    </cfif>