LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-14-2003, 04:00 AM   #1
vous
Member
 
Registered: Mar 2003
Location: Macondo
Distribution: Mandrake 9.1, 10.1, SuSE 8.1 pro, 10.1, Red Hat 8.0/9.0
Posts: 380

Rep: Reputation: 30
How to find the pid to stop a process....


Hello All,

I would like to know how can I find out which process (pid) is running on a certain port so I can stop it?

I can imagine it is somewhere around the netstat -a command... I know the process is running on 8080....

Any thoughts...????
 
Old 08-14-2003, 04:13 AM   #2
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
ps aux
 
Old 08-14-2003, 04:20 AM   #3
vous
Member
 
Registered: Mar 2003
Location: Macondo
Distribution: Mandrake 9.1, 10.1, SuSE 8.1 pro, 10.1, Red Hat 8.0/9.0
Posts: 380

Original Poster
Rep: Reputation: 30
OK, but where in the output do I relate the port and the PID?

$ ps -aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 1336 440 ? S Apr03 2:07 init
root 2 0.0 0.0 0 0 ? SW Apr03 0:00 [migration_CPU0]
root 3 0.0 0.0 0 0 ? SW Apr03 0:00 [migration_CPU1]
root 4 0.0 0.0 0 0 ? SW Apr03 0:01 [keventd]
....

Last edited by vous; 08-14-2003 at 04:26 AM.
 
Old 08-14-2003, 04:46 AM   #4
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Do you know the name of the process? If you do, the second entry in ps above ( root 2 0.0... ) is the PID.

To kill it:
kill -15 2
Where 2 is the pid of the process (assuming the process you wanna kill is migration_CPU1 ).

So further down your ps string, find the name of the process and kill it similarly. If 15 doesn't kill it, send:
kill -9 pid
instead. A 9 signal is not as clean as a 15, but sometimes is necessary.

For stopping an httpd server though (assuming apache):
apachectl stop
Should suffice...

Cool
 
Old 08-14-2003, 04:57 AM   #5
vous
Member
 
Registered: Mar 2003
Location: Macondo
Distribution: Mandrake 9.1, 10.1, SuSE 8.1 pro, 10.1, Red Hat 8.0/9.0
Posts: 380

Original Poster
Rep: Reputation: 30
OK, but my question was how do you know ON WHICH PORT that pid is running?

Any other thoughts...??
 
Old 08-14-2003, 05:12 AM   #6
vous
Member
 
Registered: Mar 2003
Location: Macondo
Distribution: Mandrake 9.1, 10.1, SuSE 8.1 pro, 10.1, Red Hat 8.0/9.0
Posts: 380

Original Poster
Rep: Reputation: 30
I figured it out...it is:

$ netstat -nap | grep 8080
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 2352/tnslsnr
 
Old 08-14-2003, 05:18 AM   #7
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Re: How to find the pid to stop a process....

Quote:
Originally posted by vous
Hello All,

I would like to know how can I find out which process (pid) is running on a certain port so I can stop it?
Your question was kind of vague, but even so, it wasn't exactly what you decided... You found which port, but then you've also now found out how to stop it

Cool
 
  


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
Getting PID of running process in C/C++ laikos Programming 16 10-30-2015 07:16 PM
Getting pid of a process!! vishamr2000 Programming 34 03-12-2015 08:12 AM
how to get more process' info according to its PID? iclinux Programming 1 02-05-2005 06:30 AM
using bash to find the pid of a process called "name" poiuytrewq Linux - Newbie 3 10-25-2004 10:01 PM
Get Next PID of Process Tree zer0python Programming 7 11-26-2003 12:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:31 PM.

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
Open Source Consulting | Domain Registration