[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Why does my python script run forever on windows task scheduler?

Posted on 2014-08-13
8
Medium Priority
?
1,209 Views
Last Modified: 2014-08-20
So this daily python script has been running fine since 2010 but recently the service accnt's pwd was changed and since then it stopped working. Or it runs but runs forever, with no result. This script just transfers iis log files from a different server to the one where it runs.
What I have tried so far.
1. Added the service accnt to the "Log on as a batch job" security policy.
2. edited the script to move a single log file locally
3. created a batch file and included "start C:\Python27\python.exe D:\scripts\fix_thomas_logs - edited.py". Ran the batch file, which completed and few seconds with the message Task Scheduler successfully completed task "\WebTrends\TestPythonBat" , instance "{3685c79f-925d-43dc-8520-3e6eb6f92a58}" , action "C:\Windows\SYSTEM32\cmd.exe" with return code 0. But still no output.

Is this a permissions issue? im asking this because the script stopped working since the pwd of the service accnt was changed. The scheduler is running other vbscripts and batch files as well but this is the only python script.
Please Help.
0
Comment
Question by:Nidhi Varma
8 Comments
 
LVL 29

Expert Comment

by:pepr
ID: 40260629
You should add some debugging info written to the dedicated file to find the reason. Check the code parts wrapped to the try/except construct. Simplify gradually the script to the point when you fond what part of the script is problematic.
0
 

Author Comment

by:Nidhi Varma
ID: 40260637
Hi,

I've already added the debug or try/except section to the code and that  doesn't help either. It does not give any output and keeps running until I kill the task. When I tried running through a batch file, it runs for less than a second and completes but again with no output.
0
 
LVL 29

Expert Comment

by:pepr
ID: 40260651
I do not know your script. I am not that good in guessing.
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
LVL 46

Expert Comment

by:aikimark
ID: 40262110
Did you change the authentication credentials of the scheduled task?
Is the id/password part of your Python script?
0
 
LVL 16

Expert Comment

by:Walter Ritzel
ID: 40262837
I'll ask you some questions:
1) What is the copy file command being used?
2) Since you had an error on the script, have you checked if there is space on the target folder? Also have you cleaned up the files that should be copied from source to target on target, and repeat the operation?

I'm asking this because I'm suspecting that maybe your copy command is missing a force flag or something like that, and your script got stucked in a OS question like "do you want to overwrite the file xxxx?"
0
 

Accepted Solution

by:
Nidhi Varma earned 0 total points
ID: 40262919
Resolved it, The issue was with the windows task scheduler that could not run the .py script. I ran the script through command prompt and it worked fine. I had to change the settings in the scheduler to run python .exe and give the  the .py script in the argument.
0
 
LVL 29

Expert Comment

by:pepr
ID: 40265354
If you feel my comment is rude, then sorry, but it is your own feeling. For me, it is simply difficult to guess when I do not know your script. And that's it.
0
 

Author Closing Comment

by:Nidhi Varma
ID: 40272092
I have selected my own comment as a solution because I did not get a timely or accurate response from the experts. Rather got a rude comment from the first guy.
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses
Course of the Month19 days, 17 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question