cron bash command to check & stop samba share Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
mail2rst
Posts: 138
Joined: Fri Apr 13, 2018 4:53 pm

cron bash command to check & stop samba share

Post by mail2rst »

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
"
User avatar
Joulinar
Posts: 5666
Joined: Sat Nov 16, 2019 12:49 am

Re: cron bash command to check & stop samba share

Post by Joulinar »

Hi,

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
mail2rst
Posts: 138
Joined: Fri Apr 13, 2018 4:53 pm

Re: cron bash command to check & stop samba share

Post by mail2rst »

thanks Joulinar, you are so much helpful.
User avatar
Joulinar
Posts: 5666
Joined: Sat Nov 16, 2019 12:49 am

Re: cron bash command to check & stop samba share

Post by Joulinar »

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
mail2rst
Posts: 138
Joined: Fri Apr 13, 2018 4:53 pm

Re: cron bash command to check & stop samba share

Post by mail2rst »

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
User avatar
Joulinar
Posts: 5666
Joined: Sat Nov 16, 2019 12:49 am

Re: cron bash command to check & stop samba share

Post by Joulinar »

thx for confirmation. I will mark the topic as solved :D
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply