I am trying to write a script that kills service running at a specific port. This is my script:a=$(ps ax | grep 4990 | grep java | awk '{print $1}')kill -9 $aIt's a java program. This script works sometimes, but mysteriously fails most of the time.Is there any other way to kill a service running on a port? My port is 4990.
Kill any service running at a specific port
process;kill;tcp