AnsweredAssumed Answered

Automated Post/Reconcile, Compress, Index, and Analyze Script Fails

Question asked by buehlerd on Aug 7, 2019
Latest reply on Jan 10, 2020 by dougbrowning

I am trying to automate my administrative processes with Python for my enterprise geodatebase.  I basically took the script at the end found here:  Use Python scripting to batch reconcile and post versions—ArcGIS Help | ArcGIS Desktop and trimmed out the parts I do not need.  I cannot for the life of me figure out why it bombs when run via a scheduled task.  

 

Using 10.6.1, sde is the admin level, gis user is the owner of the data.  

 

import arcpy
#, time, smtplib

# Set the workspace
arcpy.env.workspace = r'C:\Users\GISAdmin\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\SDE to GIS2.sde'
# sde is the user that can disconnect users
# gis is the owner of of all the data


# Set a variable for the workspace
adminConn = arcpy.env.workspace

# Block new connections to the database.
print("The database is no longer accepting connections")
arcpy.AcceptConnections(adminConn, False)
print("Credit Card Declined")

# Wait 15 minutes
#time.sleep(900)

# Disconnect all users from the database.
print("Disconnecting all users")
arcpy.DisconnectUser(adminConn, "ALL")
print("Disconnected Users")

# Get a list of versions to pass into the ReconcileVersions tool.
# Only reconcile versions that are children of Default
print("Compiling a list of versions to reconcile")
verList = arcpy.ListVersions(adminConn)
#versionList = [ver.name for ver in verList if ver.parentVersionName == 'sde.DEFAULT']
print verList

# Execute the ReconcileVersions tool.
print("Reconciling all versions")
arcpy.ReconcileVersions_management(adminConn, "ALL_VERSIONS", "sde.DEFAULT", u'WEBSERVICES.WebEdits', "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_TARGET_VERSION", "POST", "KEEP_VERSION", "c:/ArcGISscripts/ReconcileLogs/Temp/reconcilelog.txt")
print("Reconcile Complete")

# Run the compress tool.
print("Running compress")
arcpy.Compress_management(adminConn)
print("Compression Complete")

# Allow the database to begin accepting connections again
print("Allow users to connect to the database again")
arcpy.AcceptConnections(adminConn, True)
print("Communications Back On Line Captain")

# Update statistics and indexes for the system tables
# Note: to use the "SYSTEM" option the user must be an geodatabase or database administrator.
# Rebuild indexes on the system tables
print("Rebuilding indexes on the system tables")
arcpy.RebuildIndexes_management(adminConn, "SYSTEM")
print("Rebuilt Indexes")

# Update statistics on the system tables
print("Updating statistics on the system tables")
arcpy.AnalyzeDatasets_management(adminConn, "SYSTEM")
print("Analyzed Data sets")


print("YAY!!! We Finished For Once.")

Outcomes