Checking before start and stop processes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking before start and stop processes
# 1  
Old 07-22-2005
Checking before start and stop processes

Hi,

I have 2 start and stop sh.

Start sh
--------
This will start few processes.
Example code:

echo "start process : lgz200 /pipe=test_jobs"
nohup lgz200 /db=test/test1@test1 /pipe=test_jobs > ../log/lgz200_j.log &
echo "echo \"stop process (pid=$!): lgz200 /pipe=test_jobs\"" >> test_stop
echo "kill -9 $!" >> test_stop

echo "start process : lgz210 /pipe=test_jobs"
nohup lgz210 /db=test/test1@test1 > ../log/lgz210.log &
echo "echo \"stop process (pid=$!): lgz210 /pipe=test_jobs\"" >> test_stop
echo "kill -9 $!" >> test_stop

chmod 744 test_stop

exit 0

test_stop script (auto generated from start script)
--------------
echo "stop process (pid=155164): lgz200 /pipe=test_jobs"
kill -9 155164
echo "stop process (pid=128078): lgz210 /pipe=test_jobs"
kill -9 128078

Problem
-------
I wish to include checking in start and stop script like:
start - check if the process name is exist, if exist no action. else start a new process.
stop - a loop to check if the process still exists, if exist, kill it.

this 2 checking is to make sure there are no duplicate process that will be run concurently from start script and to make sure we will completely kill the process in stop script.

I am still beginner in unix, can anyone help me to show me some sample code to do the 2 checkings? Any other suggestion will be most welcomed.

Thank you very much for your help.

Regards,
weihann.
# 2  
Old 07-22-2005
# 3  
Old 07-22-2005
thanks vino for the reply.

but how abt the making sure the process will be terminated successfully?
# 4  
Old 07-22-2005
Get the process name. From that the process id.

Issue a kill -9 pid.

Possibly, a [<defunct>] process will still be there in the process list.

Removing that from your process list, requires something else. I do not have an idea as to what it is.

Some else could chip in at this time.

Vino
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. SCO

Stop boot system at "Checking protected password and checking subsystem databases"

Hi, (i'm sorry for my english) I'm a problem on boot sco unix 5.0.5 open server. this stop at "Checking protected password and checking subsystem databases" (See this image ) I'm try this: 1) http://www.digipedia.pl/usenet/thread/50/37093/#post37094 2) SCO: SCO Unix - Server hangs... (9 Replies)
Discussion started by: buji
9 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. SuSE

List of processes/ which ones to stop

Hi there, I've install a testserver with SLES 11.0! I'll install/test XEN + WebServer not all things at the moment! In a first time, I'd like to stop all unuse processes... but I don't understand all processes! As someone a list of all processes with his signification and which should/could... (3 Replies)
Discussion started by: hiddenshadow
3 Replies

4. 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

5. 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

6. 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

7. UNIX for Advanced & Expert Users

How to log start/stop time of ALL processes

Hi all, I joined this forum today and this is my first question. I thank you all for viewing it. I will try to be brief. The OS: HP-UX B.11.11 U 9000/800 There are lot of cron scheduled perl scripts running on this server, which do different things at different time. Some of them process... (10 Replies)
Discussion started by: bluesky099
10 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