Proxmox: list and batch-set VM and LXC startup order

List Proxmox containers and VMs by startup order, then set their boot priority, startup delay and shutdown timeout from the shell.

On this page

I wanted one list showing which Proxmox containers and VMs start first, and which ones shut down last. Opening each guest’s options gets old pretty quickly.

This command reads the local node’s guest configs and prints the settings together. Run it in Bash on the Proxmox host as root. It’s read-only.

List the current order

This is the original command I use regularly, split across lines so it’s easier to read and copy:

Terminal window
printf "%-6s %-5s %-32s %-8s %-8s %-8s %-8s\n" "TYPE" "ID" "NAME" "ONBOOT" "ORDER" "UP" "DOWN"
printf "%-6s %-5s %-32s %-8s %-8s %-8s %-8s\n" "------" "-----" "--------------------------------" "--------" "--------" "--------" "--------"
for f in /etc/pve/lxc/*.conf /etc/pve/qemu-server/*.conf; do
[ -f "$f" ] || continue
id=$(basename "$f" .conf)
case "$f" in
*/lxc/*) type="LXC" ;;
*/qemu-server/*) type="VM" ;;
esac
name=$(awk -F': ' '/^(hostname|name):/{print $2; exit}' "$f")
onboot=$(awk -F': ' '/^onboot:/{print $2; exit}' "$f")
startup=$(awk -F': ' '/^startup:/{print $2; exit}' "$f")
order=$(printf '%s' "$startup" | grep -oE 'order=[0-9]+' | cut -d= -f2)
up=$(printf '%s' "$startup" | grep -oE 'up=[0-9]+' | cut -d= -f2)
down=$(printf '%s' "$startup" | grep -oE 'down=[0-9]+' | cut -d= -f2)
printf "%-6s %-5s %-32s %-8s %-8s %-8s %-8s\n" "$type" "$id" "${name:--}" "${onboot:-0}" "${order:--}" "${up:--}" "${down:--}"
done | sort -k5,5n

There’s one catch: numeric sort puts the - entries at the top. Proxmox starts guests with no explicit order after those with an order. Also, ONBOOT=0 means the guest won’t start automatically at host boot. The table includes all local guests, including those excluded from automatic startup.

The output is something like this below:

Terminal window
TYPE ID NAME ONBOOT ORDER UP DOWN
------ ----- -------------------------------- -------- -------- -------- --------
VM 110 debian13a 0 - - -
LXC 104 mqtt 1 2 5 120
LXC 103 debian13d 1 3 10 120
VM 105 debian13c 1 4 20 180
LXC 112 debian13b 1 5 5 120
LXC 108 debian13e 1 6 5 120
LXC 109 pocketid 1 7 5 120
LXC 111 obsidian-livesync 1 9 5 120
VM 122 debian13i 1 10 10 180
LXC 106 debian13h 1 11 2 120
LXC 115 homebox 1 12 2 60
LXC 100 wastebin 1 13 2 60
LXC 107 bytestash 1 14 2 60
LXC 101 debian13g 1 15 2 120
LXC 114 debian13f 1 16 5 -

For configured orders, lower numbers start first. To display those in reverse, change the final sort to sort -k5,5nr. That’s useful for reading shutdown order, with the same caveat about unset values. Names containing spaces can shift the sort column too. This command suits simple hostnames like mqtt and home-assistant.

Meaning of the column values

ColumnMeaning
ONBOOT1 enables automatic startup when the host boots.
ORDERStartup priority. Lower numbers start first; shutdown uses the reverse order.
UPDelay in seconds after starting this guest before starting subsequent guests.
DOWNGraceful shutdown timeout in seconds before the guest is forcibly stopped.

So order=2,up=5,down=120 means start at priority 2, wait 5 seconds before moving on, and allow up to 120 seconds for shutdown. DOWN isn’t a separate shutdown priority. A - means the setting wasn’t explicitly saved, not that its effective value is zero.

These rules apply within one host. HA-managed guests follow HA handling instead. A startup delay also doesn’t check whether MQTT, DNS or another application is ready. See the Proxmox startup and shutdown documentation (opens in a new tab).

Set one guest, or a batch

Replace these example IDs with your own. Use pct for containers and qm for VMs:

Terminal window
pct set 104 --onboot 1 --startup order=2,up=5,down=120
qm set 105 --onboot 1 --startup order=4,up=20,down=180

For a few guests, a small table is easier to adjust. Each row below contains the command, guest ID, order, startup delay and shutdown timeout:

Terminal window
while read -r tool id order up down; do
"$tool" set "$id" \
--onboot 1 \
--startup "order=$order,up=$up,down=$down" || break
done <<'EOF_GUESTS'
pct 104 2 5 120
pct 103 3 10 120
qm 105 4 20 180
EOF_GUESTS

These guests will start automatically when the host boots, using the settings above. They won’t start or stop right now. If a command fails, the loop stops. Changes already made stay saved.

Before changing anything, copy the current onboot and startup values from pct config ID or qm config ID. To undo a change, set those previous values again. If startup was originally absent, remove it with pct set ID --delete startup or the equivalent qm command.

Check what was saved

Rerun the listing, or check individual guests:

Terminal window
pct config 104 | grep -E '^(onboot|startup):'
qm config 105 | grep -E '^(onboot|startup):'

In the batch example, container 104 starts before 103, then VM 105. Shutdown goes the other way: 105, 103, 104. Put a service’s dependencies earlier in the order so they can stay running until that service has shut down.

Comments

← All posts

Type to search the published collection.