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
Diff b/n kill and kill -9 ammu UNIX for Advanced & Expert Users 2 07-18-2007 05:29 PM
kill(0,-9) don't kill the process umen High Level Programming 9 06-19-2007 06:09 AM
not able to kill find with kill -9 Amardeep UNIX for Dummies Questions & Answers 5 01-04-2007 05:49 PM
When kill doesnt work, how to kill a process ? VijayHegde UNIX for Advanced & Expert Users 3 05-12-2006 04:24 PM
Is there a way to kill 100's of PID's? darthur UNIX for Dummies Questions & Answers 2 04-04-2002 12:29 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 10-17-2006
rkrgarlapati rkrgarlapati is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 31
KILL PID, intern should kill another PID.

Hi All,

In my project i have two process runs in the back end.
Once i start my project, and execute the command ps, i get below output:

PID TTY TIME CMD
9086 pts/1 0:00 ksh
9241 pts/1 0:02 java
9240 pts/1 0:00 shell_script_bg


java with 9241 PID is the main process which runs my whole application.
if i have to say in one word, java process has the whole control of my app.

shell_script_bg with 9241 PID is the shell script, which starts the java command.

If i kill the java PID with kill -9 9241 , which shuts my complete application. But if i kill shell_script_bg pid, it not making my application go down.

My requirement is if i kill one PID it should intern kill java PID as well.
what r the changes i need to make in my shell script or any where else.

This is an urgent requirement. plz help me.

Regards,
Ravi.
  #2 (permalink)  
Old 10-17-2006
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Try with SIGTERM:
Code:
kill <shell_script_pid>
(kill sends SIGTERM -15- by default)
Regards.
  #3 (permalink)  
Old 10-17-2006
rkrgarlapati rkrgarlapati is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 31
thanks grial,

i think i had not explained in a proper way.

PID TTY TIME CMD
9086 pts/1 0:00 ksh
9241 pts/1 0:02 java
9240 pts/1 0:00 shell_script_bg


i mean to say if i kill the PID 9240 which belong to shell_script_bg, this intern should kill java PID 9241.

i killed the process shell_script_bg using kill -9 9240, shell_script_bg is the shell script code,

now my question is what is the code change i have to make in shell script, so that if i kill it's process ID then that should kill some other process ID (java's)internally.
  #4 (permalink)  
Old 10-17-2006
er_aparna er_aparna is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 52
small script

Hello,

You can have this small script and include that at the end of your shell script

ps > input_ps
var=`grep java input_ps|cut -d" " -f1`
kill -9 $var

See if this helps....

K Regards,
Aparna
  #5 (permalink)  
Old 10-17-2006
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Quote:
Originally Posted by rkrgarlapati
thanks grial,

i think i had not explained in a proper way.

PID TTY TIME CMD
9086 pts/1 0:00 ksh
9241 pts/1 0:02 java
9240 pts/1 0:00 shell_script_bg


i mean to say if i kill the PID 9240 which belong to shell_script_bg, this intern should kill java PID 9241.

i killed the process shell_script_bg using kill -9 9240, shell_script_bg is the shell script code,

now my question is what is the code change i have to make in shell script, so that if i kill it's process ID then that should kill some other process ID (java's)internally.
It was clear the first time

What I'm telling you is to use
"kill -15 <script_pid>"
instead of
"kill -9 <script_pid>".
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 02:17 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