Can anybody tell me how to handle the software watchdog in Linux?
I have a program SampleApplication
which runs continuously and I need to restart it if
You can use "Monit" utility to restart and monitor your services. Simply install by issuing command `"apt-get install monit".
If anyone has arrived at this page looking for an operating system watchdog (which is not directly what the OP wanted), this is what you need:
sudo apt-get install watchdog
service watchdog status
service watchdog start
To check that it's working execute:
tail -f /var/log/syslog | grep watchdog
You should see something like:
Jul 25 22:03:35 nuc watchdog[14229]: still alive after 733 interval(s)
Jul 25 22:03:36 nuc watchdog[14229]: still alive after 734 interval(s)
Jul 25 22:03:36 nuc watchdog[14229]: still alive after 735 interval(s)
Jul 25 22:03:37 nuc watchdog[14229]: still alive after 736 interval(s)
Jul 25 22:03:37 nuc watchdog[14229]: still alive after 737 interval(s)
I hope I'm answering the question correctly. All the other answers seem to be very different.
Use /etc/inittab
you can utilize it to start in the specific run levels and if it is killed it shall be restarted automatically
n:2345:respawn:/path/to/app
This will make it respawn in run levels 2345 you probably only need 3 and 5 but this will work fine and is built into Linux.