Tools & Add-onsPVE Tools
PVE LXC Cleaner
Delete logs, caches and temporary files inside all LXC containers on a node and refresh their package lists.
clean-lxcs.sh frees disk space inside containers. For each container it empties /var/log and /tmp, clears the package cache and updates the package lists.
Website entry: clean-lxcs. Source: tools/pve/clean-lxcs.sh.
Run
In the Proxmox VE host shell, as root:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/clean-lxcs.sh)"Prompts
| Dialog | Choices | Effect |
|---|---|---|
| "This will clean logs, cache and update package lists on selected LXC Containers. Proceed?" | Yes / No | No exits. |
| "Select containers to skip from cleaning:" (checklist) | All containers from pct list | Ticked containers are skipped. Cancel exits. |
What it runs
Containers with an ostype other than debian, ubuntu, alpine or centos are skipped. A stopped container (that is not a template) is started, given 5 seconds, cleaned and shut down again.
Which commands run is decided inside the container:
| Detected by | Commands |
|---|---|
/etc/alpine-release exists | apk cache clean, delete all files in /var/log, delete everything in /tmp, apk update |
/etc/redhat-release exists | yum clean all, delete all files in /var/log, delete everything in /tmp, yum update, yum upgrade -y |
| otherwise (Debian/Ubuntu) | delete all files in /var/cache, delete all files in /var/log, delete everything in /tmp, apt -y --purge autoremove, apt -y autoclean, apt update |
Containers in which the cleaning failed, or that could not be started, are listed at the end and the script exits with 1.
Environment variables
| Variable | Default | Purpose |
|---|---|---|
COMMUNITY_SCRIPTS_CORE_URL | https://raw.githubusercontent.com/community-scripts/core/main | Base URL the script loads api/api.func from. |
Limits
- The deletion cannot be undone. Log files are removed, not rotated; services that keep a log file open continue writing to the deleted file until they are restarted.
- On Debian and Ubuntu every file under
/var/cacheis deleted, not only the APT cache. Applications that keep data there rebuild it. - Files in
/tmpthat a running application is using are deleted as well. - On CentOS containers the script does more than clean:
yum upgrade -yinstalls package updates. - The dialog title reads "Proxmox VE LXC Updater"; this is the cleaner.