Select to view content in your preferred language

Python scripts  do  not run complete on Sheduled task

7178
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
I have always had best luck with the scheduler if I set up a batch file that runs my script, then schedule the batch file.

my batch files that work on version 10.0 machine is:

C:

cd C:\Python26\ArcGIS10.0

Python D:\baks\dont_use\compact1.py



Exit


Then just navigate to this bat file in the task scheduler.  Will fill in the "Start in" box for you. 
Just make sure the path is correct for your python, and script.

R_[ATTACH=CONFIG]24974[/ATTACH]
0 Kudos
MichaelVolz
Esteemed Contributor
Sorry Tamadie as my last post gave you incorrect information

Cut the path from Start in and paste it into the Add arguments box

then try running your script


I usually use bat files to call python scripts, but this should now work.
0 Kudos
TAMARADIEZ
Deactivated User
Hi,

I did it but the task did not complete. It is still calling notepad.

Thanks,
0 Kudos
TAMARADIEZ
Deactivated User
Hi,

I do not have any buffers set up. They are 7 scheduled tasks each one pointing to a different python script. So each script is different.

Thanks,

T


Hi, did you say your scripts stop working on the 29th May?
Thanks,
0 Kudos
MichaelVolz
Esteemed Contributor
Tamadie:

You might want to check with IT people at your organization to see if this server gets automatic OS updates.  If so, you might want to see if there was an update on May 29.  If there was, you might want to see if they can revert back to the OS before this update and then see if your scheduled task runs.

You could also try running your scheduled task from a bat file that calls the python script.
0 Kudos
RhettZufelt
MVP Notable Contributor
I see you are on a newer OS than XP, so here is my scheduled task action that works in win7.

[ATTACH=CONFIG]24984[/ATTACH]

and this is the contents of the oracle.bat file:

cd C:\Python27\ArcGIS10.1

Python C:\arcgisserver\python\oracle.py


Exit


This is working for me.

Also, if you are opening Notepad on execute, then I'd bet that your file association has changed somehow (maybe editing .py files in Notepad?).
In windows explorer, if you right-click on a .py file and select Properties, on the General tab, it should say

Type of file :  PY File (.py)
Opens with:  (If this says Notepad, there is the issue), needs to be python.  However, since I am on a 64 bit machine with server, both 32 and 64 bit versions are on my computer, so, in order to get it to run the 32 bit (so I have access to catalog paths), I have the Opens with set to idle.bat (which is this one C:\Python27\ArcGIS10.1\Lib\idlelib\idle.bat), otherwise it trys to run in 64 bit IDE.

R_
0 Kudos
TAMARADIEZ
Deactivated User
Hi,

Yes, I updated my new script with Notepath and it seems to be it  changed all the python scripts to Notepad. To convert the scripts to Python, I right click on the script and then Open With,  chosed open with  "Choose Default Program = Python". On properties, general it appears type of file = python, opens with = python.


Then, I right clik on the script , Open with and both NotePad and Python are the options.

I ran the script it is still calling NotePad.

Any more ideas please?

Thanks,

T
0 Kudos
MichaelVolz
Esteemed Contributor
Tamadie:

Go into Windows Explorer and navigate to a python file

Right click on the python file and select Properties from the drop-down menu

Make sure the General tab then has the focus when you are in Properties

Near the top there is Opens with: Notepad.exe  Change button - I'm thinking this is what it looks like for you

It should say Opens with: python.exe

So hit the Change button and select python.exe, hit OK and then hit Apply in the General tab

Now when you right click on the python file you should see "Edit with IDLE" as the 2nd item in the drop-down menu

(Right now when NotePad is the default application to open you just see "Edit" as the 2nd item in the drop-down menu

I hope this helps.
0 Kudos
TAMARADIEZ
Deactivated User
[PHP][/PHP]

Hi Michael,

I have done it and I can  see ""Edit with IDLE" when I right click on the python file. I ran the task and still do not complete. It is calling Notepad.  I also created the batch file, create the task and ran it. The task appears as complete but the data is not updated.

Any more ideas please?

Thanks,

T
0 Kudos
MichaelVolz
Esteemed Contributor
Can you provide your python script?

Are you writing to a file geodatabase on a network drive?
0 Kudos