Simple reset script - ping

SamTzu

Active Member
I noticed that there does not seem to be a simple reset / reboot script for problematic clients so I made one.
Copy / Paste this to autorestart-vm1100.sh using nano

#! /bin/bash
# Replace VM id number and IP address with your own "VM" id number and IP address
ping -c 1 10.168.100.100 &> /dev/null && echo "Ping OK - VM 1100" || /usr/sbin/qm stop 1100 && /usr/sbin/qm start 1100 && echo "No response: Restarting VM 1100"

Remember to:
chmod +x /root/autorestart-vm1100.sh

Add this "oneliner" to run every hour on cron like this...
On your host use crontab -e to add this line:
@hourly /root/autorestart-vm1100.sh

Restart your cron
service cron restart
 
Last edited:

LnxBil

Famous Member
Feb 21, 2015
6,294
777
163
Saarland, Germany
If your guest OS (QEMU/KVM VM) really crashes, just use a watchdog device and configure it in your guest. I'm using it for years.

If you have external monitoring set up for your PVE host, why don't you just use it to restart/reboot the machines, e.g. Nagios/Icinga have actions that will trigger if e.g. monitoring cannot query the guest os. Seems a much cleaner solution that creating another DIY script for that.
 
  • Like
Reactions: rursache

rursache

New Member
Jul 7, 2022
10
1
3
Romania
radu.ursache.ro
If your guest OS (QEMU/KVM VM) really crashes, just use a watchdog device and configure it in your guest.
I totally agree with you that a proper WatchDog config is 10 times better than a bad bash script. However it was easier for me to just write this quick script until i have time to actually fix the VM crash. I'm still new to Proxmox and hypervisors
 

SamTzu

Active Member
If your guest OS (QEMU/KVM VM) really crashes, just use a watchdog device and configure it in your guest. I'm using it for years.

If you have external monitoring set up for your PVE host, why don't you just use it to restart/reboot the machines, e.g. Nagios/Icinga have actions that will trigger if e.g. monitoring cannot query the guest os. Seems a much cleaner solution that creating another DIY script for that.
Most of our VM's are LXC containers.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!