Created
October 24, 2017 15:47
-
-
Save SamEureka/9913efae6584abed827eca4d72c7d196 to your computer and use it in GitHub Desktop.
check script
This file contains 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 | |
# Create an array with the screen instance names. (The screen names are 10 characters because I suck at REGEX) | |
LIST=(`screen -list |grep -o '[a-z]\{10\}'`) | |
# Iterate over the array to do the work. | |
for i in "${LIST[@]}"; do | |
# Create a working string variable with the name | |
work="$i" | |
check=`screen -list |grep $work` | |
#check to see if the server is running | |
if [[ -z $check ]] | |
then | |
echo "${work} is not running" | |
else | |
echo "${work} is running, we are going to try an shut it down." | |
screen -S ${work} -p 0 -X stuff "stop$(printf \\r)" && | |
# sleep 15 | |
while [[ -z $truth ]]; do | |
let truth=`screen -list |grep $work` | |
if [[ -z truth ]] | |
then | |
echo "stopped!" | |
else | |
echo -r "#" | |
echo -r "$" | |
fi | |
done | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment