kill grep process code example

Example 1: kill app at port

#To list any process listening to the port 8080:
lsof -i:8080

#To kill any process listening to the port 8080:
kill $(lsof -t -i:8080)

#or more violently:
kill -9 $(lsof -t -i:8080)

Example 2: how to kill tasks using grep

kill -9 $(ps aux | grep KeyWordHere | awk '{print $2}')

Example 3: kill port

lsof -i:8080

Example 4: find and kill process

Find PID of process to kill with:
ps ax
Then just specify "kill PID" command as for example:
kill 16320
kill -9 16320 	#Force kill in case process is not answering.

Tags:

Ruby Example