Technical

Proxmox Hookscript Not Running: Trace the Invocation Path and Fix It

Proxmox Hookscript Not Running: Trace the Invocation Path and Fix It

Proxmox hookscript not running? The script fires as root during specific task phases, but its output only shows up in the task log. So if yours is silent, the first thing is to trace the invocation path instead of guessing.

A high-tech command center with illuminated digital screens in a futuristic setting.

How the hookscript gets called

When you set a hookscript on a VM (via qm set <vmid> --hookscript <storage>:<script>), it’s not run by the web UI. It’s executed by the pve-guests service, which handles VM lifecycle events. The script receives the VMID and the phase as arguments, like pre-start, post-start, pre-stop, etc. It runs as root, with no environment variables set unless you define them yourself.

Here’s the thing: if the script isn’t executable, nothing happens. No error in the GUI, no log entry. The task just proceeds as if there’s no hookscript at all. So the first check is always the executable bit.

chmod +x /var/lib/vz/snippets/myscript.sh

And the script must live in a storage that has the “Snippets” content type enabled. If you put it on a directory storage that only allows ISOs, Proxmox will silently ignore it. You can check with pvesm status and pvesm list <storage> to see if the snippet is visible.

Detailed black and white close-up of an audio mixer highlighting various control knobs and switches.

Where the output goes

Any echo or printf in the hookscript goes to the task log for that specific operation. So if you start the VM, look at the task log for the start operation, and you’ll see your output there. If you don’t, the script isn’t being called at all. That’s the quickest way to tell if the hook is even being invoked.

If you want to log to a file instead, you can redirect in the script itself, but remember it runs as root, so the file will be owned by root. That’s fine for debugging.

Common failure points

  • Script not executable.
  • Storage not enabled for snippets.
  • Wrong phase name — check the exact spelling in the docs.
  • Script has a syntax error — test with bash -n script.sh.
  • VM has no hookscript configured — verify with qm config <vmid> | grep hookscript.

One more thing: if you’re editing the script and it still doesn’t run, make sure you’re not hitting a cached version. Proxmox reads the script fresh each time, so no restart needed. But if you change the hookscript assignment, you need to update the VM config.

Honestly, the most common issue I’ve seen is the executable bit. People copy a script over, forget to chmod it, and then wonder why nothing happens. The task log is your friend — if you don’t see your debug output there, the script isn’t running.

Related: Unable to Start VM with Hookscript Proxmox: Trace the Invocation Path and Fix It covers a specific failure where the VM won’t start at all.

Leave a comment

Comments are reviewed before they appear. Your email is never published.