Servers Stop and Start


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Servers Stop and Start
# 1  
Old 01-22-2009
Servers Stop and Start

Hi,
Every time i want to stop and start servers using PuTTY,i have to execute 6 to 10 commands every time ,i need shell script(program) for execute those commands in single command.Is it possible plz suggest me.
# 2  
Old 01-22-2009
Sure is this possible, that's one of the thing shell scripts are good for. Get your favouite editor, vi for example and go! Don't forget to make the shell script executable with "chown" and best give it a suffix like .sh.

Example shell script could look like:

Code:
#!/bin/sh

start_apps()
{
     startapp1
     startapp2
     startapp3
}

stop_apps()
{
     stopapp3
     stopapp2
     stopapp1
}


case $1 in
    start)    start_apps;;
    stop)     stop_apps;;
    *)        echo "only start or stop accepted!"
              exit;;
esac

exit 0


Last edited by zaxxon; 01-22-2009 at 02:11 AM..
# 3  
Old 01-22-2009
Servers stop and start

Thankq you very much.One more need is i have 4instances for each server so i want to stop or start each instance i need userinterface to enter particular instance name(server name).I am new to unix shell script so tell me how to do it as program.

-------------------------------------------------------------------
Quote:
Originally Posted by zaxxon
Sure is this possible, that's one of the thing shell scripts are good for.

Example:

Code:
#!/usr/bin/ksh
 
start_apps()
{
     startapp1
     startapp2
     startapp3
}
 
stop_apps()
{
     stopapp3
     stopapp2
     stopapp1
}
 
 
case $1 in
    start)    start_apps;;
    stop)     stop_apps;;
    *)        echo "only start or stop accepted!"
              exit;;
 
exit 0

# 4  
Old 01-22-2009
With instances I guess you mean database instances of any kind. Maybe it is ok for you to get the environment like this and then start the stuff you have to start:

Example:
Code:
...
su - user1 -c "startinst1"
su - user2 -c "startinst2"
...

The environment from the .profile etc. will be taken into account. Also if you don't have to be the user but need the environment, you can also just "source" the environment files for your instances with this:

Example:
Code:
. /path/to/environment/file/of/instance1/.profile
. /path/to/environment/file/of/instance1/.special_env

With "env" you can see what is set in your current environment.

Best play around with all this to get a feeling for it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to specify start and stop of a search string

I am trying to extract a string from a line of text. Currently I am using grep -o 'startofstring(.........' The string is not always the same size. The string I'm trying to extract starts with 'test(' ends with ')'. ex "blah,blah,blah,test(stringoftext),blah blah" How do I... (4 Replies)
Discussion started by: jeepguy
4 Replies

2. UNIX for Dummies Questions & Answers

factor [start[stop]

Another question for you guys! This is so fun. So I am playing around with the factor operation. I read in "man factor" that you can actually print a list of primes in between a range, using the syntax factor ] However, every time I enter two values, it just returns the factored value.... (1 Reply)
Discussion started by: statichazard
1 Replies

3. UNIX for Dummies Questions & Answers

Stop/Start vs. Restart

Is there any functional difference between: issuing separate stop/start commands like this; super (handler) (instance) stop super (handler) (instance) start versus issuing a single recycle command like this; super (handler) (instance) restart (3 Replies)
Discussion started by: Newbix
3 Replies

4. Solaris

How to start/stop processes

Please anyone tell me In my last interview the HR asks me how to monitor, start,stop & kill the various processes and subprocesses. Please anyone explain me clearly. It's my personal request (3 Replies)
Discussion started by: suneelieg
3 Replies

5. Shell Programming and Scripting

Servers Start and Stop

HI I am using below code to start and stop servers but it is not working ,how to run the script please suggest me ,if any errors in the script please let me know. #!/bin/bash IMS_START="/Webserver/AppServer/bin/startServer.sh" IMS_STOP="/Webserver/AppServer/bin/stopServer.sh" case "$1" in ... (1 Reply)
Discussion started by: RG18173
1 Replies

6. Shell Programming and Scripting

Start Stop Restart

I'm wondering how I should make a script that can start, stop, and restart another script. What I need to be able to do, is start and stop a perl script from the command line. The easiest way of doing this seems to be to have another script, starting and stopping the other script. I have BASH,... (7 Replies)
Discussion started by: Bakes
7 Replies

7. HP-UX

ypbind start/stop

Hi, How to start or stop ypbind on HP-UX machine. Searched a little but could not find. thanks, (2 Replies)
Discussion started by: jredx
2 Replies

8. AIX

Start Stop Apache

I am in the process of reorging my Lawson db. I need to turn off the RMI server...not a problem. However my instructions also state that I must also shutdown my Servlet Container....I believe it is Apache. I have looked in /usr/apache/bin/apachectl What is the command for stopping and... (2 Replies)
Discussion started by: MILLERJ62
2 Replies

9. UNIX for Dummies Questions & Answers

Stop/Start proftpd

Hi everyone, I was wondering how to configure ftp access for one user when I found this board. After some searches I found my infos around proftpd (and the great config file proftpd.conf who answered to all my dreams...) but now I only need to stop proftpd and restart it (I guess it is needed... (1 Reply)
Discussion started by: Lomic
1 Replies

10. UNIX for Dummies Questions & Answers

Start/Stop Script

I'm a newbie to the Unix world Help! I have to maintain a host of Sybase database servers sitting on Unix Sun Solaris 8...I've been tasked with finding/creating a way to auto start/stop Unix via unix commands, specifically when the Unix servers need to be restarted we want Sybase to start... (2 Replies)
Discussion started by: jjv1
2 Replies
Login or Register to Ask a Question