Last active
March 16, 2023 03:08
-
-
Save andrewriveradev/6fa70a3fb9247c47c6d1f413d3014047 to your computer and use it in GitHub Desktop.
killport.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Context: | |
| # - add killport.sh to path export PATH="$HOME/bin:$PATH" assuming $HOME/bin is where you keep your scripts | |
| # - make killport.sh executable chmod +x killport.sh | |
| # write the command to kill the process running on the port | |
| kill -9 $(lsof -t -i:$1) | |
| # write command to notify the user that the process has been killed or not | |
| if [ $? -eq 0 ] | |
| then | |
| echo "Process running on port $port has been killed" | |
| else | |
| echo "No process running on port $port" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment