1

I want to kill process that runs at some port. In ubuntu I used fuser -k 8000/tcp. What is the Mac OS way?

I found out this way:

lsof -i tcp:8000
kill -9

But it's very long. I need one short command like fuser

Thanx

migrated from stackoverflow.com Nov 30 '15 at 18:13

This question came from our site for professional and enthusiast programmers.

  • lsof -i :8000 tcp:8000 + kill -9. But that are two non-short commands. I wanna one short. – Vassiliy Vorobyov Nov 30 '15 at 16:58
  • I don't know if apple uses a bash shell, but if that is the case the question is relevant here.. – sjsam Nov 30 '15 at 17:06
  • But this question already has an answer here – sjsam Nov 30 '15 at 17:11
  • Mac OS X does use bash, but that's irrelevant to the question. – chepner Nov 30 '15 at 17:39
4

Save this in some file that is in your PATH, call it kill-server for example. Make sure to chmod +x on it.

#! /bin/bash

lsof -i tcp:8000 | grep -v PID | awk '{print $2}' | xargs kill

Then invoke it with kill-server or whatever you decided to call it. This is about as short as it gets.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .