How to shutdown Proxmox 6 from CLI?

vikas027

New Member
May 27, 2019
7
4
3
41
I am using Proxmox Virtual Environment 6.0-4 on HP Z620 workstation server. Sometimes after clicking "Shutdown" the server hangs forever, I have looked at the logs but could not find anything useful. \

What is the correct order to shutdown the systemd services? I want to try shutting down proxmox gracefully and attempt to shutdown the OS using poweroff command.

root@proxmox:~# systemctl list-unit-files --state=enabled | grep ^pve
pve-cluster.service enabled
pve-firewall.service enabled
pve-guests.service enabled
pve-ha-crm.service enabled
pve-ha-lrm.service enabled
pve-manager.service enabled
pvebanner.service enabled
pvedaemon.service enabled
pvenetcommit.service enabled
pveproxy.service enabled
pvestatd.service enabled
pve-daily-update.timer enabled
pvesr.timer enabled
root@proxmox:~#
 
Poweroff takes already care of the correct order, so just use it and look at the screen for possible errors.
As I said, the system froze and there was no trace of any logs, thus I wanted to test the shutdown process without Proxmox.
 
From doing systemd-analyse and systemctl list-unit-files I came up with the following script for disabling and and enabling Proxmox services and related daemons. In order to start stuff up again you need to reboot, to make sure you get a clean boot in the right order. Your mileage may vary but I have used it quite ok for when I'm configuring non PVE stuff and I'm rebooting all the time and want PVE out of the way. Use at your own risk, but hope this helps:
Bash:
#!/bin/sh                                                                       
                                                                                
usage()                                                                         
{                                                                               
    echo "Usage: disable-enable-pve enable|disable" >&2                         
}                                                                               
                                                                                
# I have already permanently disabled this timer, you may have not.             
# services="pve-daily-update.timer                                             
services="pvesr.timer                                                           
          pve-manager.service                                                   
          pvenetcommit.service                                                 
          pve-lxc-syscalld.service                                             
          pvebanner.service                                                     
          pve-firewall.service                                                 
          pve-ha-lrm.service                                                   
          pvestatd.service                                                     
          pve-ha-crm.service                                                   
          pve-guests.service                                                   
          pvedaemon.service                                                     
          pveproxy.service                                                     
          pve-cluster.service                                                   
          lxc-monitord.service                                                 
          lxc-net.service                                                       
          lxc.service                                                           
          lxcfs.service
          rrdcached.service
          spiceproxy.service
          iscsi.service
          iscsid.service
          open-iscsi.service"

if test $# -ne 1 -o \( "$1" != "enable" -a "$1" != "disable" \)
then
    usage
    exit 1
fi

for s in $services
do
    echo "${s}:"
    if test "$1" = "enable"
    then
        systemctl unmask $s > /dev/null
        systemctl enable $s > /dev/null
    else
        systemctl stop $s > /dev/null
        systemctl disable $s > /dev/null
        systemctl mask $s > /dev/null
    fi
done
systemctl list-unit-files | egrep 'pve|lxc|rddcache|iscsi' | sort

if test "$1" = "enable"
then
    echo "All PVE services re-enabled, please reboot."
fi

exit 0

Tony.
 

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!