Reboot on failed Ping

BlueLegoFreaK

New Member
Sep 2, 2023
4
0
1
I'm trying to get my Proxmox host to reboot when it fails to ping out of the network. I wrote a script that works outside of a cronjob, but when i try to have it automate it using crontab it doesn't even register in the logs what there was an error

Currently my cron job looks like this.

*/5 * * * * cd /root/My_Scripts && ./reboot

I checked the permissions for the script and everyone has executable permissions.

This is the current state of the reboot script

ping -c1 1.1.1.1
if [ $? -eq 0 ]
then
echo "Good Ping"
else shutdown -r
fi

Do y'all have any idea on how to fix this?
 
I'd recommend you rethink a reboot on single ping failure/timeout. But if thats what you want, then change your double line, which is not quoted properly for cron to: /root/My_Scripts/reboot

Note that its not enough for "everyone" to have X, they/everyone also need to have read permission to /root and My_Scripts.

You also need full path to "shutdown", ie /usr/sbin/shutdown


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
I'd recommend you rethink a reboot on single ping failure/timeout. But if thats what you want, then change your double line, which is not quoted properly for cron to: /root/My_Scripts/reboot

Note that its not enough for "everyone" to have X, they/everyone also need to have read permission to /root and My_Scripts.

You also need full path to "shutdown", ie /usr/sbin/shutdown


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Thank you so much. I have been banging my head against this wall for the better part of today. The reason I want to do this is because i currently have the r8169 drivers, and my system will not pull the dependents for me to get the r8168 driver. I am using this as a temp fix until either the driver gets fixed or my box gets the dependents.