Bash script require to restart the tomcat on remote server.
i need a bash scrtip which prompt which server you want to restart the tomcat process suppose i have 3 servers i just run the bash script its prompt three server
1.server1 2.server2 3.server3 if i press 1 its restart the tomcat service on server1.I know that how to ssh the remote server without password. |
Look at the select statement, followed by a case structure.
Why not simply use which server as an argument to the script (followed by 'case') instead of prompting with a menu? You could even configure bash completion to display the three arguments if you don't remember. |
i am using centos 5.5.I dont how to write bash script?
|
|
I would start by making sure you have a procedure to restart those tomcats. Bash script is just an automation tool but you must be able to restart it manually first. That is yu probably need to SSH into your server and execute shutdown/startup commands.
|
In Ubuntu.
/etc/init.d/apache2 restart In RedHat service httpd restart You can use something like this #!/bin/bash ssh $1 /etc/init.d/apache2 restart |
this is what i am asking from this forum
#!/bin/bash
echo "adserver2 press 2 : " echo "adserver3 press 3 : " echo "adserver4 press 4 : " echo -n "Enter numnber : " read n if [ $n -eq 2 ] then echo "server 1" ssh root@10.179.50.46 '/etc/init.d/httpd status && exit' fi #else #if [ $n == 2] # echo "server 2" #fi # #else #if [$n == 3] # echo "server 1" #fi |
1. Like wigry said, first ensure you've got the right cmd by testing it manually.
You've actually used 'status' when it should be 'start' (or restart). 2. use code tags to post code https://www.linuxquestions.org/quest...do=bbcode#code 3. I'd recommend using consistent numbering; you're code starts talking about adserver2, then echoes "server 1" ; that's just going to confuse people, inc you .... 4. Read those links in my post #4; they'll show you how to construct a shell script. |
Tomcat not apache server
Guys he is asking a different thing He is asking for tomcat and all the answers here are about apache
|
All times are GMT -5. The time now is 01:38 PM. |