I have a Windows 2016 server running an Oracle database that needs to be manually shutdown before the server shuts down.
I enabled the local GPO (Computer Configuration > Windows Settings > Scripts > Shutdown) and attached the shutdown script to it (below), but now it takes an extra ten minutes to shutdown (this script should only take 30sec to execute). This is a problem because the UPS will generally shut the server off before its finished shutting down.
I read somewhere that the default time Windows gives for shutdown scripts is ten min before it ends the process, so I'm worried that its not even executing properly, and there is no way to tell if it is.
Stop-oracle.cmd
*********************
@ECHO OFF
net session >nul 2>&1
if %errorLevel% == 0 (
goto runControlScript
) else (
echo Administrative permission required!
goto exit
)
:runControlScript
:: variables
SET IFS_HOME=E:/H381
SET INSTANCE=H381-IFS
SET JAVA_HOME=%IFS_HOME%/mw_home/java
SET TOOL_CLASSES=%IFS_HOME%/repository/installer/templates/j2ee/as/mws-svr-ctrl.jar
SET JAVA_OPTIONS=%JAVA_OPTIONS% -DIFS_HOME=%IFS_HOME% -DINSTANCE=%INSTANCE%
SET CLASSPATH=%IFS_HOME%/mw_home/mws/wlserver/modules/features/wlst.wls.classpath.jar;%TOOL_CLASSES%
:: check if we should pause after running the app
%JAVA_HOME%/bin/java -cp .;%CLASSPATH% %JAVA_OPTIONS% com.ifsworld.mws.utils.ShouldPause "/cmdline=%cmdcmdline%" "/cmd=%~0" %*
:: non 0 errorlevel indicates that we should pause the script
set _SHOULD_PAUSE_=%ERRORLEVEL%
:: run the app
%JAVA_HOME%/bin/java -cp .;%CLASSPATH% %JAVA_OPTIONS% com.ifsworld.mws.ServerController /user=ifs /password=Im9ract1ca1 /action=STOP /target=all %*
IF %_SHOULD_PAUSE_% NEQ 0 (
PAUSE
)
ECHO "Stopping the Database"
oradim -SHUTDOWN -SID H381CDB -SHUTTYPE srvc,inst -SHUTMODE immediate
IF %errorLevel% == 0 (
ECHO IFS and Database shutdown Command Completed
PAUSE
)
IF %_SHOULD_PAUSE_% NEQ 0 (
PAUSE
)
:exit
ENDLOCAL