I'm trying to do a comms loss auto restart and just found this script online (bless the person who did it). the script is
ping -c4 www.site.com > /dev/null if [ $? != 0 ] then sudo /sbin/shutdown -r now fi
so this script works perfectly fine. what i wanted to do was add another script with the same function but instead of pinging a site, i wanted to add another so it can ping a server, so what i did was same script but just change what it was pinging
ping -c4 192.168.1.5 > /dev/null if [ $? != 0 ] then sudo /sbin/shutdown -r now fi
i am storing this script on
/usr/local/bin/ so the filename on the first script for the comms loss is
/usr/local/bin/commsloss.sh and then the filename of the second script is
i've added both of these lines on
*/5 * * * * /usr/bin/sudo -H /usr/local/bin/commsloss.sh >> /dev/null 2>&1
*/10 * * * * /usr/bin/sudo -H /usr/local/bin/serverloss.sh >> /dev/null 2>&1
and then i tried turning off the server to see if it will restart but it didn't work.
i was wondering if this would work or if this is the correct syntax to use so that i can just have one script instead of two?
ping -c4 www.site.com > /dev/null || ping -c4 192.168.1.5 > /dev/null