Salesforce

How to shut down the Database and Adminserver on Windows before manually restarting the system?

« Go Back

Information

 
TitleHow to shut down the Database and Adminserver on Windows before manually restarting the system?
URL NameP179385
Article Number000136494
EnvironmentProduct: OpenEdge
Version: 10.x, 11.x, 12.x
OS: Windows Server
Question/Problem Description
How to shut down the Adminserver on Windows when the system is restarted
How to shut down the database on Windows when the system is restarted
Is there a way to assure the Adminserver is terminated when the system restarts?
How to prevent database abnormal shutdown recovery when the Windows Server is restarted by system updates?
How to nicely shutdown a Database during Windows shutdown or reboot?
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
IF NOT EXIST batchfile.bat GOTO DOESNOTEXIST

'enter your command lines here'

:DOESNOTEXIST

'continue here'


Example: SHUTDB.bat

SET LOGFILE="c:\Temp\shutdown.log"
SET DATE=%mm%%dd%%yyyy%
echo %DATE% %TIME% "START Shutting down databases" >> %LOGFILE%
REM  Replace the following with your DB's to be shutdown, include FULL PATH or set a %DBPATH% variable to use.
DBPATH="Put the path to the directory with the database here with a closing \"
START /B CALL _mprshut %DBPATH%dbname1 -by -shutdownTimeout immed
START /B CALL _mprshut %DBPATH%dbname2 -by -shutdownTimeout immed
START /B CALL _mprshut %DBPATH%dbname3 -by -shutdownTimeout immed
echo %DATE% %TIME% "START Shutting down OpenEdge AdminService >> %LOGFILE%



SET /A loopcount=0


:LOOP
SET /A loopcount+=1
IF "%loopcount%" == "4" (
 GOTO end
 ) ELSE (
REM The timeout operation waits the specified time before moving to the next command (equivalent to sleep on Unix)
REM This will pause at least 30 seconds before testing if the .lk file of one or more database exists.
REM If only one database is being tested remove the IF EXIST dbname2.lk
TIMEOUT 30 /NOBREAK

REM If more than two databases are being tested add more IF EXIST dbname<#>.lk before the GOTO operation in the following line
IF EXIST %DBPATH%dbname1.lk IF EXIST %DBPATH%dbname2.lk IF EXIST %DBPATH%dbname3.lk GOTO LOOP
ELSE GOTO DOESNOTEXIST    
 )

:DOESNOTEXIST
NET STOP "AdminService for OpenEdge 11.7"
echo %DATE% %TIME% "DONE!" >> %LOGFILE%
::exit
EXIT /B


:end
REM Consider emailing Administrator because at the end of the loop count at least one of the database .lk files still exists
REM Consider emailing Administrator because at the end of the loop count at least one of the database .lk files still exists
REM The following line aborts the shutdown as long as this script is within the shutdown time window
shutdown /A 

The above script might be named script to-check-if-dbs-fully-shutdown.bat
The following is a possible scenario of how the above script might be invoked.
If a script existed that automated shutdown and stopping the database such as:
REM the following command will cause Windows to wait 300 seconds (5 minutes) and restart
shutdown /t 300
REM the following is the launching of a script that will stop all databases
call script-to-stop-dbs.bat
REM the following is a script to stop the AdminService
call scrip-to-stop-adminservice.bat
REM the following is a script to check that the databases are all shutdown and if 
REM the databases do not shutdown to abort the restart of the machine and send some form of alert
REM to the administrator
call script to-check-if-dbs-fully-shutdown.bat
Workaround
Notes
Keyword Phrase
Last Modified Date5/20/2022 1:08 PM

Powered by