I want to make one bash file which can executed daily to check whether samba share is active or not? & if it is still running then stop it & if its not running then nothing to do. if i need this service i will start that application with any other methodology in future. please check my bash file & help me to fine tune it.
thanks
"
#!/bin/bash
service=smbd
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
/etc/init.d/$service stop
fi
"
Hi,
you could do it as one-liner
/bin/systemctl is-active --quiet smbd && /bin/systemctl stop smbd
thanks Joulinar, you are so much helpful.
maybe you can share if this is working.
thanks Joulinar,
your one line command works for me. so i have not put if condition. just your one line & my system works as per intended use. thanks
thx for confirmation. I will mark the topic as solved