Skip to content

Instantly share code, notes, and snippets.

@Maykonn
Last active January 24, 2019 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maykonn/fe8c47d0770dd6f1beef38968857a0f6 to your computer and use it in GitHub Desktop.
Save Maykonn/fe8c47d0770dd6f1beef38968857a0f6 to your computer and use it in GitHub Desktop.
This gist is a .sh file which test if a service is running, you may change as necessary for your needs
#!/bin/bash
local_mysql_service=mysql
if (( $(ps -ef | grep -v grep | grep ${local_mysql_service} | wc -l) > 0 ))
then
service ${local_mysql_service} stop
fi
echo "Conflicting local services stopped ($local_mysql_service), continue..."
local_apache_service=apache2
if (( $(ps -ef | grep -v grep | grep ${local_apache_service} | wc -l) > 0 ))
then
service ${local_apache_service} stop
fi
echo "Conflicting local services stopped ($local_apache_service), continue..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment