Scheduled tasks

We are using Lucee 5.2.3.35. We have a CFM file that we need to run as a scheduled task. When the task runs, it actually redirects to our applications login page, so it appears as though it never ran. We have included the user name and password on the scheduled tasks screen, but it doesn’t seem to take.

How can we have this task run once per day and use a pre-determined username/password so it doesn’t wait for a user to input one (which they never will as they never see the output as its running as a task).

Tanks,
Harry

Why doesn’t it take? What happens if you open the link in a private/incognito window?

It actually DOES take, but the application is set up that it forces a redirect to the login page if the user isn’t logged in. This doesn’t work for a scheduled task, so I need to find a way to get around that. I thought that putting the username and password in the Scheduled Task would do that, but apparently it doesn’t.

Thanks,

Harry

Why can’t you just modify the application behavior?

You could also move the scheduled task file to it’s own directory with it’s own Application.cfc (thus avoiding the need for a login) and server based protection on the directory (to secure the file, if necessary).

Its in its own directory already, but we took this project over and don’t really know CFM very well. Enough to be dangerous. How would I configure Application.cfc to do what you suggest?

Thanks,

Harry

ok, try this, before the code which does the login redirect add

param name="url.loginRedirect" default="true";
or
<cfparam name="url.loginRedirect" default="true">

the before the problematic redirect, just add

if (url.loginRedirect)...

or

<cfif (url.loginRedirect)>...

then append &loginRedirect=false to your scheduled task url ?

1 Like

Sure sorry simply create a file named Application.cfc in this directory with the following contents

component {
    this.name = "YourScheduledTaskFolderApplicationName";
 }
1 Like