I don't see in your script where you are disconnecting the users
arcpy.DisconnectUser("Database Connections/admin@sde.sde", "ALL")
Many thanks Carl for the answer. Sorry for the confusion1. Below is the code that I need to have a SCRIPT TOOL (in a toolbox) for (As I don�??t have sufficient skills to do so):-------------------------------------------------------------------------import arcpy, time, smtplib# set the workspace arcpy.env.workspace = 'Database Connections/admin.sde'# set a variable for the workspaceworkspace = arcpy.env.workspace# get a list of connected users.userList = arcpy.ListUsers("Database Connections/admin.sde")# get a list of usernames of users currently connected and make email addressesemailList = [u.Name + "@yourcompany.com" for user in arcpy.ListUsers("Database Connections/admin.sde")]# take the email list and use it to send an email to connected users.SERVER = "mailserver.yourcompany.com"FROM = "SDE Admin <python@yourcompany.com>"TO = emailListSUBJECT = "Maintenance is about to be performed"MSG = "Auto generated Message.\n\rServer maintenance will be performed in 15 minutes. Please log off."# Prepare actual messageMESSAGE = """\From: %sTo: %sSubject: %s%s""" % (FROM, ", ".join(TO), SUBJECT, MSG)# Send the mailserver = smtplib.SMTP(SERVER)server.sendmail(FROM, TO, MESSAGE)server.quit()#block new connections to the database.arcpy.AcceptConnections('Database Connections/admin.sde', False)# wait 15 minutestime.sleep(900)#disconnect all users from the database.arcpy.DisconnectUser('Database Connections/admin.sde', "ALL")# Get a list of versions to pass into the ReconcileVersions tool.versionList = arcpy.ListVersions('Database Connections/admin.sde')# Execute the ReconcileVersions tool.arcpy.ReconcileVersions_management('Database Connections/admin.sde', "ALL_VERSIONS", "sde.DEFAULT", versionList, "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_TARGET_VERSION", "POST", "DELETE_VERSION", "c:/temp/reconcilelog.txt")# Run the compress tool. arcpy.Compress_management('Database Connections/admin.sde')#Allow the database to begin accepting connections againarcpy.AcceptConnections('Database Connections/admin.sde', True)#Get a list of datasets owned by the admin user# Get the user name for the workspace# this assumes you are using database authentication.# OS authentication connection files do not have a 'user' property.userName = arcpy.Describe(arcpy.env.workspace).connectionProperties.user# Get a list of all the datasets the user has access to.# First, get all the stand alone tables, feature classes and rasters.dataList = arcpy.ListTables('*.' + userName + '.*') + arcpy.ListFeatureClasses('*.' + userName + '.*') + arcpy.ListRasters('*.' + userName + '.*')# Next, for feature datasets get all of the featureclasses# from the list and add them to the master list.for dataset in arcpy.ListDatasets('*.' + userName + '.*'):dataList += arcpy.ListFeatureClasses(feature_dataset=dataset)# pass in the list of datasets owned by the admin to the rebuild indexes and analyze datasets tools# Note: to use the "SYSTEM" option the user must be an administrator.arcpy.RebuildIndexes_management(workspace, "SYSTEM", dataList, "ALL")arcpy.AnalyzeDatasets_management(workspace, "SYSTEM", dataList, "ANALYZE_BASE", "ANALYZE_DELTA", "ANALYZE_ARCHIVE")--------------------------------------2. Here is the code that has already a script tool (attached to my previous post)---------------------------# Name: GDBMaintenance.py# Description: Rebuilds indexes and statistics # on geodatabase feature classes# using an existing .sde file.# Author: Esri# Import system modulesimport arcpy, osimport sys, traceback # set the workspace environment using the data owner account D:\Practical2_Editing\Data\Sa_A.sdepath=arcpy.GetParameterAsText(0)arcpy.env.workspace = path ############################################################Gather all the FeatureClasses and Tables from the Workspacedatasets = arcpy.ListTables() + arcpy.ListFeatureClasses()#Save geodatabase path to use for concatonating feature dataset namespath = arcpy.env.workspace#Determine if any were foundfor fd in arcpy.arcpy.ListDatasets("","Feature"): arcpy.env.workspace = path + "\\" + fd #Gather the FeatureClasses from the Current Dataset datasets += arcpy.ListFeatureClasses()arcpy.env.workspace = path#Rebuild and analyze all datasetsarcpy.RebuildIndexes_management(arcpy.env.workspace,"NO_SYSTEM",datasets,"ALL")print arcpy.GetMessages()arcpy.AnalyzeDatasets_management(arcpy.env.workspace,"NO_SYSTEM",datasets,"ANALYZE_BASE","ANALYZE_DELTA","ANALYZE_ARCHIVE") print arcpy.GetMessages()#Rebuild and analyze all system tables and compress the Geodatabase# set the workspace environment using the Geodatabase administrative accountarcpy.env.workspace = path ######################################################arcpy.RebuildIndexes_management(arcpy.env.workspace,"SYSTEM","","ALL")print arcpy.GetMessages()arcpy.AnalyzeDatasets_management(arcpy.env.workspace,"SYSTEM","","ANALYZE_BASE","ANALYZE_DELTA","ANALYZE_ARCHIVE") print arcpy.GetMessages()arcpy.Compress_management(arcpy.env.workspace)print arcpy.GetMessages()print "Processing complete"-------------------------------BestJamal
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine