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
"
cron bash command to check & stop samba share Topic is solved
Re: cron bash command to check & stop samba share
Hi,
you could do it as one-liner
you could do it as one-liner
Code: Select all
/bin/systemctl is-active --quiet smbd && /bin/systemctl stop smbd
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Re: cron bash command to check & stop samba share
thanks Joulinar, you are so much helpful.
Re: cron bash command to check & stop samba share
maybe you can share if this is working. 

Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Re: cron bash command to check & stop samba share
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
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
Re: cron bash command to check & stop samba share
thx for confirmation. I will mark the topic as solved 

Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team