Created
February 11, 2017 11:13
-
-
Save itang/342ba16bd03005044ea6a0bebac7eda5 to your computer and use it in GitHub Desktop.
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 | |
| port=$1 | |
| if [ "$port" = "" ]; then | |
| echo "please input the port for check!" | |
| exit 1 | |
| fi | |
| max_attempts=10 | |
| attempts=0 | |
| echo "lsof -i $port" | |
| while [ "`lsof -i TCP:$port`" != "" ] | |
| do | |
| echo "alive..." | |
| if [ "$attempts" = "$max_attempts" ]; then | |
| ./stop force | |
| exit 0 | |
| fi | |
| echo "try $attempts, sleep 1" | |
| sleep 1 | |
| (( attempts += 1)) | |
| done | |
| echo "$port not alive!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment