The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to log start/stop time of ALL processes bluesky099 UNIX for Advanced & Expert Users 10 12-18-2007 12:01 AM
Start Stop Apache MILLERJ62 AIX 2 12-27-2005 05:40 PM
Help: how to start/stop FTP server in solaris? eddsos SUN Solaris 1 08-07-2005 01:32 PM
Stop/Start proftpd Lomic UNIX for Dummies Questions & Answers 1 12-09-2004 09:38 AM
Start/Stop Script jjv1 UNIX for Dummies Questions & Answers 2 12-16-2003 04:28 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-21-2005
maldini maldini is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 21
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 (permalink)  
Old 07-22-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
This might help you.

How to check if another instance of the process is running

vino
  #3 (permalink)  
Old 07-22-2005
maldini maldini is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 21
thanks vino for the reply.

but how abt the making sure the process will be terminated successfully?
  #4 (permalink)  
Old 07-22-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0