Simple bash script to kill a process which uses the specified port.
Simply make a directory in which to store the script, i.e. /opt/scripts/killport
, clone this repository therein, set the script to executable, and add this path your $PATH environment variable, as follows:
mkdir -p /opt/scripts/killport && cd /opt/scripts/killport
git clone https://github.com/xtrasimplicity/killport.git .
chmod +x killport
echo 'export PATH="$PATH:/opt/scripts/killport"' >> ~/.bashrc
source ~/.bashrc
Simply run killport as follows:
killport PORT_NUMBER
i.e. killport 3000
By default, killport sends each process a SIGTERM
signal, allowing the process to gracefully terminate.
If you want to forcefully terminate the process, you can pass the -f
option to have killport send a SIGKILL
signal.
i.e. killport -f 3000
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D