Last active
May 15, 2024 22:32
-
-
Save Esl1h/eafc5c287ba7f291152213e10831f2b1 to your computer and use it in GitHub Desktop.
Programming Bash/Shell Classes - Just a little exercise to discover over systemctl and ps commands if a web server are running or not - one in a million of alternatives
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 | |
function runcheck { | |
printf "\n" && echo -ne 'Systemctl: ' && systemctl status $SERVICE | grep 'active' | cut -d ' ' -f 7-8 | |
printf "\n" && echo -ne 'Process: ' && ps -ef | grep $SERVICE | grep -v grep | tr -s ' ' | cut -d ' ' -f 2-10 | head -n 1 | |
} | |
PS3="Select the service: " | |
select SERVICE in nginx httpd apache2 | |
do | |
runcheck | |
break; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment