on 09-17-2013 9:08 AM
Hi All,
Can anyone give me the shell script to stop and start the sap system?
I would be executing the following commands by using the below mentioned id's
<SID>adm : stopsap
ora<SID> : lsnrctl stop
<SID>adm :saposcol -k
<SID>adm : cleanipc all remove
Where should i keep the particular script to get executed on a particular day at a particular time?
Any suggestions would be appreciated.
Best Regards,
Mano
Thanks Abarajith and Matthias for your suggestions. I have executed the above mentioned script and stopped/started the systems.Now i am looking for the negative scenarios where any one of the command fails. I almost got the script.Looking for the right time to execute the script. Will let you know the commands, once it comes out successful.
Best Regards,
Mano Balaji
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Eimler,
Thanks. so we can capture the exit code in a variable and based on the exit code, we can proceed to stop the system.What if the listener control fails? is there any possibility to check that?
Best Regards,
Mano Balaji
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Elimler. we have stopped and started the system with the help of this script. This executes correctly when all of the commands works as expected. In worst case scenario, is there any possibility to get back to the previous state if any one of the command fails within the script.
Best Regards,
Mano Balaji
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mano,
no. If the stopsap fails you have to analyze the problem. But instead of stopsap you could use
sapcontrol -nr 00 -prot NI_HTTP -function Shutdown
Then you can test the exitcode
EXITCODES
0 Last webmethod call successful
1 Last webmethod call failed, invalid parameter
2 StartWait, StopWait, WaitforStarted, WaitforStopped, RestartServiceWait
timed out
3 GetProcessList succeeded, all processes running correctly
4 GetProcessList succeeded, all processes stopped
And if it is not equal 0 you can stop the script and send a mail with sendmail.
Best regards
Willi Eimler
Hello,
Please use crontab to schedule your script periodically.
1.prepare your script (su - sidadm & orasid is must) as every one mentioned above.
2.log in as "root" in the host
3. command "crontab -e"
4. crontab file will be opened.you can edit crontab as you do in vieditor (i-insert then insert the following value)in the last line
#comment for your script.
0 0 * * 0 su - sidadm stopsap r3 <DIhost>
5 0 * * 0 su - sidadm stopsap r3 <CIHOST>
10 0 * * 0 su - orasid lsnrctl stop <LISTENER_NAME>
15 0 * * 0 su - sidadm stopdb
20 0 * * 0 su - sidadmcleanipc all remove
25 0 * * 0 su - sidadm startdb
30 0 * * 0 su - orasid start lsnrctl <LISTENER_NAME>
35 0 * * 0 su - sidadm startsap r3 <CIHOST>
40 0 * * 0 su - sidadm startsap <DIHOST>
then save it by :wq
Note: "0 0 * * 0" (every week Sunday at 12:00 AM all the year, All the month it will run)is given for weekly basis. you can refer the following and can understand how to give convenient time intervals as per your requirement.(the time values without space and the command should be separated by a space)
Minute | Hour | Day | of | Month | Month | Day of week | Command |
(0-59) | (0-23) | (1-31) | (1-12 | or | Jan-Dec) | (0-6) or (Sun-Sat) |
Regards,
Abarajith V
Hi Eimler,
I have written the script to startsap. Script executes the commands from <sid>adm properly.Initially it starts the saposcol.
But when it comes to ora<sid>, it is getting interupted at the line showing lsnrctl>.
Then i have to manually type "start" to start the listener control and then type "exit" to exit from listener control.Then it automatically executes startsap.
One more thing, i haven't included double quotes("") while executing the commands in script.'
I have given just su - <orasid> -c lsnrctl start.
Is it necessary to include double quotes?
Best Regards,
Mano Balaji
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Eilmer,
Thanks a lot for your suggestion. I will try out this thing and let you know the result.
Best Regards,
Mano Balaji M
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Eirnler for your suggestion.I like to get this script executed automatically at a particular point of time.Can u give me the shell script for that? Thanks in advance.
Best Regards,
Mano Balaji M
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mano,
Make the following scrtipt e.g. /usr/sap/MySAPscripts/StopMySAP
#!/bin/sh
# StopMySAP : Name of Script
su - <sidadm> -c "stopsap"
su - <orasid> -c "lsnrctl stop"
su - <sidadm> -c "saposcol -k"
su - <sidadm> -c "cleanipc all remove"
And then put /usr/sap/MySAPscripts/StopMySAP into crontab
look at:
http://www.adminschoice.com/crontab-quick-reference/
or
http://www.computerhope.com/unix/ucrontab.htm
Best regards
Willi Eimler
Best regards
Willi Eimler
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.