Select to view content in your preferred language

Script runs fine from command window but not in Server2008 scheduler

2351
3
Jump to solution
08-07-2012 07:23 AM
NICHOLASCALLAGHAN
Deactivated User
I have the following batch file running every night at 4am.  It does not complete.  However, if I run the command at the command window it runs successfully.  My python script (which follows) seems to run well also.  Please any assistance of getting this running as a scheduled task in Server 2008 would be much appreciated.

Batch file:

rem-----
D:\Python27\ArcGIS10.1\python.exe D:\ArcGISprj\Ciims\geoProccessing\CIIMS_UPDATE.py


Python Script:  Called CIIMS_UPDATE.py referenced in the batch file above

# Import arcpy module
import arcpy

# Local variables:
fcCrossing = "Database Connections\\sdedev.sde\\SDE.CIIMS\\SDE.Static_Crossings"
lyrXYCross = "lyrXYCross"
TblAtlasCrossings = "Database Connections\\SDEDev.sde\\SDE.CIIMS_VWCROSSINGGIS3" #this is a view from CANSYS that exists in the CIIMS Schema
fldLONG="CROSSINGLONGITUDE"
fldLAT="CROSSINGLATITUDE"
PrjLL='GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433],AUTHORITY["EPSG",4326]]'
locklev ="Database Connections\\sdedev.sde"
#CIIMSUser = "SDE" #DisconnectUser will not disconnect the user who is executing the function, so "ALL" is used for now.
#outpath = "Database Connections\\sdedev.sde\\SDE.CIIMS\\"
#outnames = "sde_Static_Crossings"
#SDE_Static_Crossings_1 = "Database Connections\\SDEDev.sde\\SDE.CIIMS\\SDE.Static_Crossings"

arcpy.env.overwriteOutput=True

# Process: Make XY Event Layer
arcpy.MakeXYEventLayer_management(TblAtlasCrossings, fldLONG, fldLAT, lyrXYCross, PrjLL, "")

#to avioud Schema alteration, select and delete the data from the crossing feature class in SDE, Static Crossings
#arcpy.DeleteRows_management (fcCrossing)
#arcpy.DeleteFeatures_Management(fcCrossing)
#for some reason, when we deleteFeatures and remove the locks, we dont see any remaining tablespace for hte Static_Crossings. 
#since its working, we go ahead, disconnect user locks and copy management vs copy_features_Management to copy the event table to the feature class
#remove all the locks
arcpy.DisconnectUser(locklev, "ALL")

#delete the layer of importance fccrossing/static crossings
# Process: Delete
arcpy.Delete_management(fcCrossing, "FeatureClass")

#remove all the locks
arcpy.DisconnectUser(locklev, "ALL")

# Process: Feature To Point
arcpy.FeatureToPoint_management(lyrXYCross, fcCrossing, "INSIDE")
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ChristopherThompson
Frequent Contributor
you have the batch file set up as a scheduled task?  is there more to it than you are showing? Otherwise, why not just call the python code without embedding it inside the .bat?  Perhaps I am missing something?  I'm not sure why the .bat wont run in that context though.  This screen shot shows how this sort of thing is set up where I am working - we have several services that run on a variety of schedules from every 5 minutes to hourly.

View solution in original post

0 Kudos
3 Replies
ChristopherThompson
Frequent Contributor
you have the batch file set up as a scheduled task?  is there more to it than you are showing? Otherwise, why not just call the python code without embedding it inside the .bat?  Perhaps I am missing something?  I'm not sure why the .bat wont run in that context though.  This screen shot shows how this sort of thing is set up where I am working - we have several services that run on a variety of schedules from every 5 minutes to hourly.
0 Kudos
MathewCoyle
Honored Contributor
Ensure your script only uses UNC paths not mapped drives, the account you are executing the task as has permissions to access an ArcGIS license and your sde connection file is not using OS authentication.
0 Kudos
NICHOLASCALLAGHAN
Deactivated User
you have the batch file set up as a scheduled task?  is there more to it than you are showing? Otherwise, why not just call the python code without embedding it inside the .bat?  Perhaps I am missing something?  I'm not sure why the .bat wont run in that context though.  This screen shot shows how this sort of thing is set up where I am working - we have several services that run on a variety of schedules from every 5 minutes to hourly.


This worked perfectly..... Being fairly new to both, I think i over thought this situation.  THANKS for you help!!!!!
0 Kudos