Skip to Content

Script to Shutodwn SAP

Hi,

I am working on the Script to shut down and start up SAP application through Batch file on Windows. I am succesfully able to execute my script. But my problem is i have 2 Node. On Node A Central instance is running and on Node B Application server is running. So right now what i am doing i am running to file on Node a and Node b to stop and start. Is there any possibility that i can shut down the Node b from my Central instance it self through script. for example this is my script and i am changing the host name and other details and running from Node b also to shut down.

echo off
cd \batchfile
CALL D:\usr\sap\NSP\SYS\exe\uc\NTI386\stopsap name=DP1 nr=00 SAPDIAHOST=sapdev >>  c:\batchfile\shutlog.txt
cd \batchfile
CALL NET stop "SAPHostControl" >> c:\batchfile\stoplog.txt
CALL NET stop "SAPHostExec" >> c:\batchfile\stoplog.txt
CALL NET stop "SAPDP1_00" >> c:\batchfile\stoplog.txt

Thanks

Subhash

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    Sep 30, 2011 at 11:16 AM

    hello,

    Best to use sapcontrol newer than stopsap

    For instance

    'sapcontrol -nr <instance nr.> -function Stop'

    Check the options for sapcontrol

    <instance nr.> stands for instance number

    regards,

    John Feely

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 24, 2013 at 06:12 PM

    Hi,

    First: I strongly recommend you to use powershell instead of bloody old and stupid cmd.exe (Batch files). With powershell it is very easy to do really complicated things where you would break your fingers trying to do it on cmd.exe.

    Second: use sapcontrol.exe instead of deprecated stopsap script - it is part of the every kernel and instance directory (/usr/sap/SID/SYS/exe/uc/ntamd64 or /usr/sap/SID/DVEBMGSxx/exe) and has a very rich functionality.

    For online help information just run it in a cmd.exe without parameters

    sapcontrol.exe is also able to work remotely:

    This command will stop all instances of a system in the right order:

    /usr/sap/SID/DVEBMGS01/exe/sapcontrol.exe -prot PIPE -nr 01 -function StopSystem ALL

    But you can also stop the system instance by instance.

    Stopping the services can be done using powershell commands:

    stop-service SAP*
    will stop all services whoes name starts with SAP.

    you can use sc.exe which is able to control services remotely.

    sc.exe <server> [command] [service name]

    For stopping SAPHostControl on computer nodeB:
    sc.exe nodeB stop SAPHostControl

    A very interesting feature of powershell is powershell remoting.
    It has features similar to ssh - so you can execute code on a remote computer.

    Here you can run a single command on several computers:
    invoke-command -computer nodeA,nodeB {stop-service SAPSID_00}

    This will stop the Service SAPxxx_01 on the local computer, the SID is not needed, because the number has to be unique on a host).

    C:/usr/sap/SID/DVEBMGS01/exe/sapcontrol.exe -prot PIPE -nr 01 -function StopService

    This will stop the Service SAPxxx_01 on the remote computer nodeB, the SID is not needed, because the number has to be unique on a host).

    C:/usr/sap/SID/DVEBMGS01/exe/sapcontrol.exe -prot PIPE -nr 01 -function StopService -hostname nodeB


    Third. SAPHostExec Service depends on SAPHostControl. Starting/Stopping SAPHostControl will also start/stop SAPHostExec.

    Forth:

    Stopping an SAP-Windows-Service will also shutdown it's instance.

    Don't waste your time writing batch scripts - use powershell!

    regards

    Peter

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 02, 2011 at 08:17 PM

    Hello Subhash

    No you would need to be on the same node

    Run command from kernel directory

    regards,

    John Feely

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 01, 2016 at 03:54 PM

    To start or stop sap system Create two Batch files as following:


    1 - StartSap.bat

    <Drive>:\usr\sap\<SID>\DVEBMGS00\exe\startsap name=SID nr=01 SAPDIAHOST=<Host name>

    <Drive>:\usr\sap\<SID>\DVEBMGS00\exe\startsap name=SRD nr=00 SAPDIAHOST=<Host Name>

    Example:

    c:\usr\sap\ERM\DVEBMGS00\exe\startsap name=SID nr=01 SAPDIAHOST=windows1Q002

    c:\usr\sap\ERM\DVEBMGS00\exe\startsap name=SRD nr=00 SAPDIAHOST=windows1Q002

    2 - StopSap.bat

    <Drive>:\usr\sap\<SID>\DVEBMGS00\exe\stopsap name=SID nr=01 SAPDIAHOST=<Host name>

    <Drive>:\usr\sap\<SID>\DVEBMGS00\exe\stopsap name=SRD nr=00 SAPDIAHOST=<Host Name>

    Example:

    c:\usr\sap\ERM\DVEBMGS00\exe\ stopsap name=SID nr=01 SAPDIAHOST=windows1Q002

    c:\usr\sap\ERM\DVEBMGS00\exe\ stopsap name=SRD nr=00 SAPDIAHOST=windows1Q002



    note : nr=" you need add row for all instants in yellow color"


    Add comment
    10|10000 characters needed characters exceeded

    • Hello Kamal,

      Thank you for the input.

      lets say i have 3 steps in my cycle 1)stop or start instances 2)update system center about system status 3) send an email.

      from the above script how to validate instances are up and running or instances are down before going to second step.

      does your script works for java and dual stack sytems...i mean does that script works to bring jstart.exe process online?