Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

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
Source by www.akamaras.com #
 
PREVIOUS NEXT
Tagged: #bash #start #service #running
ADD COMMENT
Topic
Name
2+7 =