Very occasionally openvpn or the SMB service has stopped when I’m abroad. If it’s the SMB service I can use VPN to login to ipfire and start the SMB service. However, if it’s openvpn, I can’t use my server anymore to access files.
How can I make these (or any) services automatically restart if they stop? Or maybe even just attempt to start them every, say, 24 hours, assuming they won’t start if they’re already running?
Thank you for taking the time to provide a detailed example.
I don’t have a process called samba, which is fine since you probably just gave that as an example. However, when I run
/etc/rc.d/init.d/samba status
the following is returned:
nmbd is running with Process ID(s) 22975.
smbd is running with Process ID(s) 22990 22989 22982 21569.
winbindd is running with Process ID(s) 23154 22994 22993.
Grepping for these processes returns three processes for smbd, one for nmbd and three for winbindd.
Please could you update your example for this situation?
For OpenVPN, I can’t see a script to start it /etc/rc.d/init.d/. Looking at processes, returns:
Do I need to be looking for both these processes? I noticed that there is no pid file in /var/run for the authenticator. So I can configure just one in monit.
As you can see from the output, a feature with several processes has to be handled a bit more exactly.
Samba consists of smbd (file and printer sharing) , nmbd ( NetBIOS-to-IP-address name service ), winbindd ( Name service switch ). So the information ‘smbd is not running’ doesn’t imply ‘all Samba services are not running’.
Therefore it is better to do a /etc/rc.d/init.d/samba restart. This kills all associated processes before starting the service.
Thanks. If I understand correctly, I’d check for all three processes and if the process being checked is no longer running then I should restart samba (taking Bernhard Bitsch’s comment into account).