Skip to content

Instantly share code, notes, and snippets.

@Esl1h
Last active May 15, 2024 22:32
Show Gist options
  • Save Esl1h/eafc5c287ba7f291152213e10831f2b1 to your computer and use it in GitHub Desktop.
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
#!/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