Python script performing oddly when run as a scheduled task on Windows Server

3015
17
02-29-2012 07:02 PM
JeremyRead
New Contributor II
I have setup a python script to run as a scheduled task on a server running Windows Server 2008 (which was ridiculously hard to do in itself).  I can run the task manually and it does what it is supposed to do (export a bunch of Data Driven Pages as .pdfs), however it is *not* doing two of the things it is supposed to:  1. Open a console window while it's running, 2. Send an automated email when it is done.  Now, if I just manually double-click on the script itself and run it, the command window opens and the email is sent without any issues.

Why does it not do these things when run as a scheduled task?  Is there some sort of setting that I need to change?  I'm finding scheduled tasks in Server 2008 to be very painful to try to use.  I have none of these problems when running the script as a scheduled task in Server 2003.
Tags (2)
0 Kudos
17 Replies
IvanBrown
New Contributor III
Yes.  I have both Python 2.7.2 and the Python 2.7.2 64-bit installed to 2 different directories.  The Python that is accessed by navigating through [Start | Programs | ArcGIS] is the 64-bit Python.

My Path environment variable did not include a path to the folder of the Python.exe of the non-64-bit Python;  Path variable did not include a path to the 64-bit Python either.  I added the non-64-bit Python path to my Path environment variable.  My PYTHONPATH variable was pointing to a custom module folder of an old Python 2.6.x folder.  I moved that custom module folder to my non-64-bit Python 2.7.2 installation and set PYTHONPATH accordingly (I don't think that this is a PYTHONPATH issue).

Still, same result.
0 Kudos
MichaelVolz
Esteemed Contributor
Are you using a bat file to call your python script?

Or are you calling the python script directly?
0 Kudos
IvanBrown
New Contributor III
Yes.  I tried wrapping the script with a .bat.  It did not make a difference.
0 Kudos
IvanBrown
New Contributor III
The problem even remains if I check out an ArcInfo license to this server (as opposed to using the license server, which is remote).
0 Kudos
IvanBrown
New Contributor III
I tried switching to the 64-bit Python in the Path environment variable.  The problem remained.
0 Kudos
MichaelVolz
Esteemed Contributor
Ivan:

In the Actions tab of your Scheduled Task what do you have as the following entries (Please include full path):

Program/script

Add arguments (optional)

Start in (optional)
0 Kudos
IvanBrown
New Contributor III
Now the "Arguments" and "Start In" are blank.  I did try setting the "Start In" to the full path of the script's folder.  That did not make a difference.  My script does not use arguments.
0 Kudos
MichaelVolz
Esteemed Contributor
Ivan:

So the Program/script argument has the path to the bat file including the bat file name?

And the Start in (optional) argument has the path to the folder where the above bat file resides?

This is how I have my Scheduled Task configured in Windows Server 2008 and it executes successfully.


You are running with highest privileges?
0 Kudos