Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8644

Re: Windows script to shutdown sap after server reboot

$
0
0

You can use this script if you run on Oracle, you have to adjust some parameters:

 

@ECHO OFF
setlocal
set THISHOST=<server>
set LOGFILE=%THISHOST%_stopsap_neu.log
set LOCAL=<SID>
set MYSID=<SID>
set SYSNUM=<SYSNR>
set CSYSNUM=<Central Services SYSNR>
set MYSAPPROGDIR=\\%THISHOST%\sapmnt\%MYSID%\SYS\exe\uc\NTAMD64
set MYNTREGCMD=%MYSAPPROGDIR%\ntreg2cmd %MYSID%
set MYDBSTOPCMD=%MYSAPPROGDIR%\brconnect -u / -c -f dbshut -f
if %USERNAME%=="SYSTEM" goto bad_user
tasklist | find "mmc.exe" > %LOGFILE%
if "0" == "%ERRORLEVEL%" taskkill /IM mmc.exe >> %LOGFILE%
echo %MYNTREGCMD%
%MYNTREGCMD%
call %MYSID%env.cmd
set /a MAXLOOPS=20
set /a LOOPS=0
:RESUME
set /a LOOPS=%LOOPS%+1
echo.
echo ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
echo Loop Nr.: %LOOPS%
set /a LOOPERR=0
sapcontrol -prot PIPE -nr %SYSNUM% -function StopSystem ALL >> %LOGFILE%
sapcontrol -prot PIPE -nr %SYSNUM% -function WaitforStopped 15 15 >> %LOGFILE%
sapcontrol -prot PIPE -nr %SYSNUM% -function GetProcessList >> %LOGFILE%
set /a RC=%ERRORLEVEL%
if "4" == "%RC%" set LOOPERR=0
if not "4" == "%RC%" set LOOPERR=1
if "0" == "%LOOPERR%" goto GO_ON
echo Waiting to stop...
if %LOOPS% GEQ %MAXLOOPS% goto CHKFAILED
if not "0" == "%LOOPERR%" goto RESUME
:CHKFAILED
echo.
echo Max. number of loops (%MAXLOOPS%) reached. Stop failed!
goto ENDE
:GO_ON
if not "%CSYSNUM%" == "%SYSNUM%" net stop SAP%MYSID%_%CSYSNUM% >> %LOGFILE%
net stop SAP%MYSID%_%SYSNUM% >> %LOGFILE%
echo Instance stopped, stopping DB!
echo %MYDBSTOPCMD%
%MYDBSTOPCMD%
goto ENDE
:bad_user
echo Please use SIDadm! >>\batcherr.err
:ENDE

Viewing all articles
Browse latest Browse all 8644

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>