Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Task Scheduler

Status
Not open for further replies.

Idee

Programmer
Jul 8, 2003
51
0
0
NZ
Hi

I want to schedule a task in Coldfusion. I have tried scheduling it using code and also using cfide but not able to do it. I have no clue what could be the problem.

My code is like this:

<cfscript>
End_Time = DateAdd("y",1,now());
Start_Time = now();
schedulepath = "StartDate = DateFormat(Start_Time, "mm/dd/yyyy");
StartTime = TimeFormat(Start_Time, "h:hhtt");
EndDate = DateFormat(End_Time, "mm/dd/yyyy");
EndTime = "5:30PM";
</cfscript>


<CFSCHEDULE
ACTION = "UPDATE"
TASK = "test_task"
OPERATION = "HTTPRequest"
URL = "#schedulepath#"
STARTDATE = "#StartDate#"
STARTTIME = "#StartTime#"
interval = "120"
ENDDATE = "#EndDate#"
ENDTIME = "#EndTime#"
RESOLVEURL = "Yes"
REQUESTTIMEOUT= "600">

I have also tried to schedule the task once and also given the path as
I have also created a task using cfide.
I have checked logs. The scheduler.log has 3 entries:
...Task initiated
...Task completed
Status code for task: 'test_task' is '401 Unauthorized'

All CF services are on.

Any help is appreciated

Thanks
 
Ok, we need to be clear on your problem. Is it not letting you create the scheduled task, or is it creating the task but just not running correctly?

Usually, a 401 Error: Unauthorized means the requested URL is protected from public access. Is your page in a restricted area? You may need to specify a username and password in your scheduled task.



Hope This Helps!

Ecobb

"My work is a game, a very serious game." - M.C. Escher
 
Thanks Ecobb

I am able to create the task but it's not running. I am able to access the URL otherwise in the browser without any username or password.

No, it is not in the restricted area.

Thanks again for your input and do let me know if you could think of any other reason.

 
Hi Ecobb

You were right that page was in restricted area. It has worked well now.

Another small query, in case the server is rebooted, will the scheduled tasks keep on working as they were before or they need to set up again?

Thanks


 
Glad you got it fixed! Once you schedule a task, it will continue to run as scheduled until you delete the task, so rebooting the server won't stop it (unless the server is rebooting at the same time the task is scheduled to run.)



Hope This Helps!

Ecobb

"My work is a game, a very serious game." - M.C. Escher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top