Skip to main content
Community Scripts logo
Skip to Content
Tools & Add-onsPVE Tools

PVE LXC Execute

Run one shell command inside every Debian and Ubuntu LXC container on a node.

execute.sh asks for a command and runs it with pct exec in every Debian or Ubuntu container you did not exclude.

Website entry: execute. Source: tools/pve/execute.sh.

Run

In the Proxmox VE host shell, as root:

bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/execute.sh)"

Prompts

PromptChoicesEffect
"This will execute a command inside selected LXC Containers. Proceed?"Yes / NoNo ends the script.
"Select containers to skip from executing:" (checklist)All containers from pct listTicked containers are skipped. Cancel ends the script.
Enter here command for inside the containers:Free textThe command line to run.

What it does

For every container that is not excluded:

  • Containers whose ostype is not debian or ubuntu are skipped.
  • A stopped container (that is not a template) is started, given 5 seconds, and shut down again after the command.
  • The command is first run as bash -c "command <your command> >/dev/null 2>&1". If that fails, the container is reported as has no command and skipped. If it succeeds, the command is run a second time with its output shown.

Environment variables

VariableDefaultPurpose
COMMUNITY_SCRIPTS_CORE_URLhttps://raw.githubusercontent.com/community-scripts/core/mainBase URL the script loads api/api.func from.

Limits

  • Because of the check described above, a command that succeeds runs twice in each container. Do not use it for commands that must run only once, such as appending to a file.
  • A command that exists but returns a non-zero exit code is reported as missing.
  • Alpine and other non-Debian containers are never touched.
  • The command runs as root in each container and there is no undo.