LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-25-2012, 04:00 AM   #1
acomber
LQ Newbie
 
Registered: Jan 2012
Location: London, UK
Posts: 9

Rep: Reputation: Disabled
I try kill <pid> but program still appearws if I use ps


Hello

I ran a server program (ie a program which runs and never stops) and after a while used Ctrl Z to stop the program.

Then I looked at running processes using ps and found it was listed there. so I noted the pid and ran kill <thepid>. no error seen in doing this.

Then I check using ps again and program is still listed?

Does this mean the program is still actually running? Or does it show recent processes? Or am I doing something wrong?

Angus
 
Old 01-25-2012, 04:38 AM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi Angus,

Welcome to LQ!!!

You have to send kill signal to terminate the process. You can do this using following command:

Code:
kill -9 <pid of that process>
-9 is the kill signal.

Last edited by T3RM1NVT0R; 01-25-2012 at 04:40 AM.
 
1 members found this post helpful.
Old 01-25-2012, 04:38 AM   #3
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,194
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
type this command and check the output

Code:
#jobs
 
Old 01-25-2012, 05:07 AM   #4
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Quote:
# ps aux | grep name_of_process
At the command line type: kill -9 PID_Number_Here

You can also type:

Quote:
# killall -9 name_of_process
which will kill any process with that name.

Or

Quote:
# kill -s9 name_of_process
 
Old 01-25-2012, 06:26 AM   #5
acomber
LQ Newbie
 
Registered: Jan 2012
Location: London, UK
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by T3RM1NVT0R View Post
Hi Angus,

Welcome to LQ!!!

You have to send kill signal to terminate the process. You can do this using following command:

Code:
kill -9 <pid of that process>
-9 is the kill signal.
Ah the -9 was the missing crucial piece. Many thanks.
 
Old 01-25-2012, 06:31 AM   #6
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,194
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by acomber View Post
Ah the -9 was the missing crucial piece. Many thanks.
good to know you found the solution

and next time use this command to look out for stopped or zombie process before you reach to a conclusion that you have sucessfully killed any process

Code:
#jobs
so why don't you mark the thread as solved to help others as well
 
1 members found this post helpful.
Old 01-25-2012, 06:40 AM   #7
acomber
LQ Newbie
 
Registered: Jan 2012
Location: London, UK
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by T3RM1NVT0R View Post
Hi Angus,

Welcome to LQ!!!

You have to send kill signal to terminate the process. You can do this using following command:

Code:
kill -9 <pid of that process>
-9 is the kill signal.
Thanks, I have investigated further and if I do not specify the signal to send then SIGTERM is sent. I presume the application had a handler for SIGTERM and just carried on running. No program can handle SIGKILL (-9) (as far as I am aware) so that did the trick.
 
Old 01-25-2012, 07:26 AM   #8
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

You're welcome.

Yes, you are right that no program can trap KILL SIGNAL.

Enjoy linux!!!

Last edited by T3RM1NVT0R; 01-25-2012 at 07:27 AM.
 
Old 01-25-2012, 08:24 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
When processes are killed with SIGKILL they have no opportunity to clean up before they stop so data may be lost and files may be left in an uncoordinated state. For these reasons, if the application can be stopped by any other signal, that signal should be used. SIGKILL is a last resort (unless you want the process to have no opportunity to save its data ).
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I assign a Command to a specific PID so I can kill a predetermined PID johnmccarthy Linux - Newbie 1 11-03-2011 08:41 AM
kill < file (Feeding kill from file), PID, <, awk, grep jaffd Programming 4 04-09-2010 04:06 PM
kill <pid> does not do anything moskito01 Linux - General 9 08-25-2009 12:20 PM
What is the more easier way to check the pid and kill the pid cmx08 Linux - General 5 09-09-2008 10:57 PM
kill pid.... won't work with 'pid' variable given.. sachitha Programming 6 03-06-2006 07:48 PM


All times are GMT -5. The time now is 09:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration