Answers for "bash only start a service if not running"

0

bash only start a service if not running

#!/bin/bash
service=replace_me_with_a_valid_service

if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is running!!!"
else
/etc/init.d/$service start
fi
Posted by: Guest on August-06-2021

Code answers related to "bash only start a service if not running"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language