linux - Check if service exists in bash (CentOS and Ubuntu) -
what best way in bash check if service installed? should work across both reddish hat (centos) , ubuntu?
thinking:
service="mysqld" if [ -f "/etc/init.d/$service" ]; # mysqld service exists fi
could utilize service
command , check homecoming code.
service mysqld status if [ $? = 0 ]; # mysqld service exists fi
what best solution?
rustam mamat gets credit this:
if list services, can grep results see what's in there. e.g.:
# restart apache2 service, if exists. if service --status-all | grep -fq 'apache2'; sudo service apache2 restart fi
linux bash ubuntu service centos
No comments:
Post a Comment