When trying to compress a geodatabase it's difficult to remove all of the locks within the geodatabase, especially when you have ArcGIS Server services accessing the data. This tool will shutdown all of your ArcGIS Server services, disconnect all connected geodatabase users, block further connections, reconcile/post all versions (with the option to delete the versions), compress the database, and then start all of the services. There is also an option to send an e-mail of the compress results.
Currently, this has been tested with SQL Server, PostgreSQL, and Oracle. Also, note that if you have geodatabase replicas, these should be synchronized before this tool is executed. After the tool has executed, you should rebuild indexes and update statistics.
The tool can be easily run as a script as well by commenting out the GP variables in the 'Compress Database State 0.py' file and populating the commented variables at the beginning of the script. This will allow you to easily automate this using the Windows Task Scheduler.
Update 6/13/18: Added the ability to select which services to stop/start during the compress operation. Also, the tool now outputs a CSV file reporting the before/after counts of the delta (A & D) tables for the versioned feature classes. Ex: