On linux, how can I create script to reboot server if it loses internet for x hours? [closed]

I have ubuntu server that has some services that only come back after loosing internet for an extended period of time with a reboot. Does anyone have a script that can reboot server if lose internet for like 2 hours?


You can use the watchdog daemon. It allows you to define a custom command to test whether the server should reboot (or execute a different repair binary). That command will be a script that tests whether Internet connection has been up for the past two hours (for instance, you can run a script on cron that pings an external server and stores the date and time of the last successful ping). See the man page for configuration details.

Source : Link , Question Author : CptanPanic , Answer Author : Paulo Almeida

Leave a Comment