Select to view content in your preferred language

Python scripts  do  not run complete on Sheduled task

7188
26
06-04-2013 04:09 AM
TAMARADIEZ
Deactivated User
Hi,

I have various python scripts running through scheduled tasks. Each scheduled task is pointing to a python script. They run independently.They are scheduled to run daily and have been working fine for months. Last week,  I added a new task and pointed to a new python script. It seem to be since then,  the tasks do not complete even I ran them manually. If I run the python scripts using python they work fine.


The tasks ran okay until the 29th May.  I compared the history of the tasks before the 29th May and after. I noticed in the Task Category the following difference:



1. When the task that ran properly (before 29th May), the instance is c:\python26\Arcgis10.0\python.exe
2. The same task  which does not complete after the 29th May. The instance is pointing to Notepad.exe

We use a Service account and it has the permmisions. Connections to ArcCatalog are in place.


Are you able to provide some advice please?

Thanks,

T
Tags (2)
0 Kudos
26 Replies
RhettZufelt
MVP Notable Contributor
In the ArcGIS 10.1 version (it is different for previous versions, but not sure which version you are running), I have had issues trying to associate it with python.exe.  Might be because I have both 32 and 64 bit versions installed.

However, this is what I had to do to get a python file associated with the "correct" python version to get it to run (associate with python.exe didn't work for me).

So, to make it work, this is what I did:


Go into Windows Explorer and right-click on a python file and select properties.

Click General tab, and you will see the Type of file:  Py File (.py)
and the  Opens with: *.exe

Click the Change button, then click Browse and navigate to C:\Python27\ArcGIS10.1\Lib\idlelib\idle.bat and select that file.

(in version 10.0, I have to navigate to C:\Python26\pythonw.exe to get it to work  *note, not python.exe, but pythonw.exe)

Select OK to everything, and in the end, it should look like this v10.1:

[ATTACH=CONFIG]25016[/ATTACH]

or this v10.0:

[ATTACH=CONFIG]25018[/ATTACH]

This will associate the .py files with the built in python batch file that opens with the correct version of python.

When I set it up this way, if I double click a .py file, or select it from a .bat file or scheduled task, it will run it directly with the 32 bit version of python.

R_
0 Kudos
TAMARADIEZ
Deactivated User
Hi,

I went through the steps and still does not work. I have done other test.

I ran a task with my personal account and it calls the python and works fine but with service account does not work.

It seems to be the problem is with the service account that we are using to run the tasks. The tasks seems to work until I locked the account. The account was unlocked but even so the tasks did not run ok.

I am the administrator of the sde database. The tasks are updating data within sde.

Does the service account needs permission to the sde database? Any other ideas please?

Many thanks for all your help.

T
0 Kudos
MichaelVolz
Esteemed Contributor
At this point is the task executing, but the actual update to the SDE database is not occurring?

Do you have any error checking enabled in your python script to determine what is not working?

Can you run the python script through IDLE and see if it updates the SDE database as you would expect, completely separate from the scheduled task?
0 Kudos
TAMARADIEZ
Deactivated User
Hi,
Yes, the data is updated when running the script with Idle and also when I ran the task with my user account.

Many thanks,

Regards,

Tamar
0 Kudos
TAMARADIEZ
Deactivated User
At this point is the task executing, but the actual update to the SDE database is not occurring?

Do you have any error checking enabled in your python script to determine what is not working?

Can you run the python script through IDLE and see if it updates the SDE database as you would expect, completely separate from the scheduled task?



Hi Michael,

Please see answer to your questions:

At this point is the task executing, but the actual update to the SDE database is not occurring? If I run the task manually it appears as Task complete but I cheched the data and updates were not made

Do you have any error checking enabled in your python script to determine what is not working? I do not have any error checking. I don't know how to do it. Could you tell me please?

Can you run the python script through IDLE and see if it updates the SDE database as you would expect, completely separate from the scheduled task? Yes, I ran it with IDLe and the updates as commited.

As i mentioned before we use a service account to run the task. For testing, I used my personal account and run the task manually and the changes are commited. I am the sde administrator so my account has permisions on sde.  So I think it is something to do with the service account?.

Do you know any more ideas please, this is making me crazy? Does this service account needs persmissions on the sde database?

Many thanks for all your help.

T
0 Kudos
MichaelVolz
Esteemed Contributor
Tamadie:

On your scheduled task under the General tab, do you have it set to Run whether user is logged on or not

and

Run with highest privileges

I had issues in the past if I did not have Run with highest privileges set on the scheduled task.

Does the service account you are using have Administrator privileges on the server?  You probably need this as well.
0 Kudos
RhettZufelt
MVP Notable Contributor
Any chance you have set the file association to python (instead of Notebook.exe) for the service account?

You would have to log onto the computer using this account, then go through the steps above to make sure the service account is associating the files with python.

It sounds like it is associating it correctly when using your profile.  Just a thought, try it and see if it helps,

R_

also, as Michael said above, do you have it set to run whether logged on or not?  in Win7, they use new network authentication, and I can NOT make it work with the user logged on or not as our group policy (set by the domain admins) does not allow passing the password over the network.  As a "workaround", I have to leave my scripting machine logged on at all times with my service account.
0 Kudos