Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 07-07-2005, 12:45 AM   #1
Registered: Jul 2003
Location: indore, india
Posts: 69

Rep: Reputation: 15
script/command to kill processes running on particular port

I want know, "Can we write some shell script that will kill all the processes running on particular port.. I want to run that script daily by cron... " I have written a server that runs some port say 3001 on my Mandrake server.. Now I need to restart that server daily with cron.. but when I try to end that server, its processes running on port 3001 does not terminate.. I need to kill those processes and start my server again..
I hope I am clear..

Please help
Old 07-07-2005, 01:36 AM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Something like
lsof | grep IPv | grep 3001 | awk '{print $2}' | xargs -l -i kill -9 {}
should work ...

Old 07-08-2005, 03:35 AM   #3
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Rep: Reputation: 32

that's too funny (the cross posting)

I take it back it's not mean :P


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
PID Kill Script or command ? Webmin rapture_1 Linux - General 1 11-02-2005 11:11 AM
shell script to kill all processes on specified port varunbihani Linux - General 1 04-19-2005 05:39 AM
Command to list all running processes GSX Linux - General 4 02-23-2005 03:42 AM
What command can identify processes running on ports? hello321_1999 Linux - Newbie 2 11-23-2004 05:01 AM
How can I see what process are running and how to I kill them? (command line). brynjarh Linux - Newbie 4 07-07-2004 03:01 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:34 PM.

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