The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
kill process help thms_sum Shell Programming and Scripting 5 02-03-2008 09:27 AM
how to start a process and make it sleep for 5 mins and then kill that process shrao Shell Programming and Scripting 6 03-27-2007 01:54 PM
When kill doesnt work, how to kill a process ? VijayHegde UNIX for Advanced & Expert Users 3 05-12-2006 05:24 PM
HP UX How to kill Process prakashpichika HP-UX 5 02-10-2006 01:40 AM
who -uH, kill the process at different pts/tb yls177 UNIX for Dummies Questions & Answers 3 12-11-2002 09:32 PM

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

Join Date: Jul 2001
Posts: 3
How to kill a process and get process id

I'm just new to this unix world

I need to kill a process I started using telnet, I tought that the process will be immediately terminated when I closed the telnet window but it didnt. I opened a new telnet window and the jobs where still there!, how can I kill them, and If I need a job id or something how can I get it?

My best regards to all of you

Jose Diaz
  #2 (permalink)  
Old 07-31-2001
wolf wolf is offline
Registered User
  
 

Join Date: Jul 2001
Location: South Africa
Posts: 20
To kill the process...log on with a telnet session L

$ps -ef | grep (process name)

The line will look as follows :
$ (userid) (process id) (process id2) (time) (terminal) .........
$kill -9 (process name or process id)

Hope this helps

Regards
Wolf
  #3 (permalink)  
Old 07-31-2001
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
It is safer to try other kill signals than 9... kill -9 is last resort, and should not be used on arbitrary processes. Try kill -1, kill -2, and kill -15 first. If those don't work, then use signal 9.

Also, try this:

#!/bin/sh
_id=$1

for die1 in `ps -ef | grep ^${_id} | grep -v grep | awk '{print $2}'`
do
kill -1 ${die1} >>/dev/null 2>&1
done
sleep 1
for die2 in `ps -ef | grep ^${_id} | grep -v grep | awk '{print $2}'`
do
kill -15 ${die2} >>/dev/null 2>&1
done
sleep 1
for dienow in `ps -ef | grep ^${_id} | grep -v grep | awk '{print $2}'`
do
kill -9 ${dienow} >>/dev/null 2>&1
done

echo "All processes owned by $_id should be dead now"
exit 0


It allows you to effectively kill processes owned by the user specified on the command line, slowly first, then forceful later.
Used like so:
./(scriptname) (user to kill)


HTH
  #4 (permalink)  
Old 07-31-2001
jmdiaz jmdiaz is offline
Registered User
  
 

Join Date: Jul 2001
Posts: 3
Process id or name

How can I get the process id or process name?

Again, thanks a lot!

Jose Diaz
  #5 (permalink)  
Old 07-31-2001
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Use the ps command. Check out the manual page for ps (man ps) for a huge list of options... you can display in a lot of different formats depending on your taste.
  #6 (permalink)  
Old 07-31-2001
jmdiaz jmdiaz is offline
Registered User
  
 

Join Date: Jul 2001
Posts: 3
Smile Great it worked!

Thanks folks!
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 06:26 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