LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   script/command to kill processes running on particular port (https://www.linuxquestions.org/questions/linux-general-1/script-command-to-kill-processes-running-on-particular-port-340825/)

varunbihani 07-07-2005 12:45 AM

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

Tinkster 07-07-2005 01:36 AM

Something like
Code:

lsof | grep IPv | grep 3001 | awk '{print $2}' | xargs -l -i kill -9 {}
should work ...


Cheers,
Tink

chakkerz 07-08-2005 03:35 AM

ahh

that's too funny (the cross posting)

I take it back it's not mean :P


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