Clean scheduled reboot

rethus

Active Member
Feb 13, 2010
49
0
26
What is the right way to do a clean reboot of the whole ProxMox Master node (e.g. after upgrade of pve-kernel)?

For example, I wan't to do the reboot at 23:00 tonight.
I don't think it's save, to do only an "shutdown -r 23:00" ?! I think the running VM's won't be shutdown in a clean way.. or am I wrong?

Is there a command which shutdown all VM's ? Maybe I could use this with:
Code:
<shutdown all vms here> | at 11:00 PM
shutdown -r now | at 11:05 PM

What's the recommended way to do reboot the whole Master on a given time?
 
Last edited:
there is no master node in PVE

shutting down or rebooting a node will trigger a shutdown of all guests - but you have to make sure that your guests are able to automatically shut down when triggered.
 
there is no master node in PVE

shutting down or rebooting a node will trigger a shutdown of all guests - but you have to make sure that your guests are able to automatically shut down when triggered.

This means, that 'shutdown -r 23:00' fully fits my needs ?
How can I make sure that guests are able to automatically shutdown.
 
This means, that 'shutdown -r 23:00' fully fits my needs ?
How can I make sure that guests are able to automatically shutdown.

depends on the guest operating system. it should react to ACPI power events and not require user input.
 
Did you get some experience with command line based shutdowns? For me it makes a big difference shutting down per web interface or with a commandline shutdown/reboot command. In the first case all VMs are shutdowned as well before the node follows. In the second case the VMs don't seem to be notified and the node performs the action immediately. In most cases the file systems are not unmounted properly so a consistence check is performed at boot.
 
For me it makes a big difference shutting down per web interface or with a commandline shutdown/reboot command.

The web interface simply calls the command line tools for shutdown, so this behaves exactly the same ...
 
Bash:
#!/bin/bash

# get list of VMs on the node
VMIDs=$(qm list| awk '/[0-9]/ {print $1}')

# ask them to shutdown
for VM in $VMIDs
do
    qm shutdown $VM
done


#wait until they're done (and down)
for VM in $VMIDs
do
    while [[ $(qm status $VM) =~ running ]] ; do
        sleep 1
    done
done

## do the reboot
shutdown -r now
 
Bash:
#!/bin/bash

# get list of VMs on the node
VMIDs=$(qm list| awk '/[0-9]/ {print $1}')

# ask them to shutdown
for VM in $VMIDs
do
    qm shutdown $VM
done


#wait until they're done (and down)
for VM in $VMIDs
do
    while [[ $(qm status $VM) =~ running ]] ; do
        sleep 1
    done
done

## do the reboot
shutdown -r now

How do you schedule this script ?
I get errors from crontab

Code:
/root/restart_pve.sh: line 4: qm: command not found
/root/restart_pve.sh: line 22: shutdown: command not found
 

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 yours easily in our online shop.

Buy now!