我有一台运行 Oracle 数据库的 Windows 2016 服务器,需要在服务器关闭之前手动关闭该数据库。
我启用了本地 GPO(计算机配置 > Windows 设置 > 脚本 > 关机)并将关机脚本附加到其中(见下文),但现在关机需要额外十分钟(此脚本只需 30 秒即可执行)。这是一个问题,因为 UPS 通常会在服务器完成关机之前将其关闭。
我从某处读到,Windows 为关机脚本提供的默认时间是在结束该过程之前十分钟,所以我担心它甚至没有正确执行,而且无法判断它是否正确执行。
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