Clean Up Linux, Proxmox & Docker Bloat
Without Crashing Running Services
Over time, Linux, Proxmox, and Docker hosts accumulate gigabytes of disk bloat: systemd journals, rotated log files (.gz, .1), Docker container logs, APT package archives, and trash. If left unchecked, root partitions fill up, crashing databases and stopping active services.
/root/ & Run:
đ Which Script is the Best for You?
We have organized scripts specifically tailored to your operating environment:
Ubuntu / Debian Server
ubuntu/log_cleanup.sh
đ Most balanced & safe: Cleans systemd journal logs (journalctl --vacuum-time=7d), protects security logs (wtmp / btmp), truncates without crashing services, preserves essential CLI tools, and displays a disk delta report.
- â Systemd journals vacuumed (
--vacuum-time=7d) - â Preserves auth & security logs (
wtmp/btmp) - â Truncates active container JSON logs safely
- â Shows before/after disk usage report (
df -h)
Proxmox VE Hypervisor
proxmox/proxmox-cleanup.sh
đ 100% Storage Safe: Cleans host node journals, service logs, and apt caches while enforcing strict safety rules to guarantee zero data loss in Proxmox VM storage.
- â Strictly protects VM & CT Backups (
/var/lib/vz/dump/) - â Preserves downloaded ISOs (
template/iso/) - â Preserves Container Templates (
template/cache/) - â Vacuums PVE journal logs safely
Docker Engine Host
docker/Docker_log.sh
đŗ Zero-downtime log cleaner: Safely truncates container JSON logs without stopping containers, prunes dangling images, build cache, and stopped containers while strictly preserving persistent data volumes.
- â Truncates active container logs (
*-json.log) - â Prunes dangling untagged images & stopped containers
- â Prunes unused Docker builder/buildx cache
- â Persistent volumes left 100% untouched for safety
Cacti Monitoring
cacti/cacti_log.sh
đĩ Zero-disruption Cacti cleaner: Safely truncates cacti.log and Spine poller logs without breaking file permissions, removes rotated archives, and strictly preserves all .rrd performance graphs.
- â Truncates active
cacti.log&spine.log - â Strictly protects all
.rrdgraph metric files - â Deletes compressed
.gzand rotated log archives - â Cleans Cacti boost cache & temp export spool
đ Comprehensive Feature Comparison
Compare what each script cleans and what it protects before deploying:
| Feature | ubuntu/log_cleanup.sh â | docker/Docker_log.sh đŗ | proxmox/proxmox-cleanup.sh â | cacti/cacti_log.sh đĩ | ubuntu/cleaning.sh |
|---|---|---|---|---|---|
| System Log Truncation | â
truncate -s 0 |
â (Docker logs only) | â
truncate -s 0 |
â (Cacti logs only) | â
truncate -s 0 |
| Cacti Poller & Spine Log Truncation | â | N/A | â | â
truncate -s 0 |
â (Auto-detects) |
| Container JSON Log Truncation | â (Automatic) | â
*-json.log |
â | â | â |
| Dangling Images & Build Cache Prune | â | â
docker prune |
â | â | â |
| Systemd Journal Vacuum | â
--vacuum-time=7d |
â | â
--vacuum-time=7d |
â | â |
wtmp / btmp Login Safe |
â (Protected) | N/A | â (Protected) | N/A | â |
Old Compressed Logs (.gz, .[0-9]) |
â Deleted | â | â Deleted | â Deleted | â Deleted |
| APT Cache & Autoclean | â | â | â | â | â |
Orphaned Packages (deborphan) |
â Safe | â | â Safe | â | â |
| Trash Folder Cleanup | â | â | â | â | â |
| Protects Backups & ISO Images | N/A | N/A | â 100% Untouched | N/A | N/A |
Protects RRA Graph Metrics (.rrd) |
N/A | N/A | N/A | â 100% Untouched | â Untouched |
| Displays Disk Report | â
df -h |
â
docker system df |
â | â
df -h |
â |
đ Repository Structure
Clean separation between Ubuntu/Debian, Proxmox VE, and Docker environments:
System-Cleanup-Script/ âââ ubuntu/ # Ubuntu & Debian Server Cleanup Scripts â âââ log_cleanup.sh â [BEST] Safe Ubuntu log & journal cleaner with disk report â âââ cleaning.sh # Multi-service cleaner (Nginx, Apache, MySQL, Flussonic) â âââ clean_logs.sh # Standard log and APT cache cleaner â âââ clean-logs.sh # POSIX sh cache & log cleanup â âââ clean_up.sh # General cleanup with Nginx RTMP support âââ proxmox/ # Proxmox VE Cleanup Scripts â âââ proxmox-cleanup.sh â [BEST] Storage-safe Proxmox log & cache cleaner â âââ proxmox_clean.sh # Lightweight Proxmox cleanup âââ docker/ # Docker Optimization & Cleanup â âââ Docker_log.sh đŗ Truncates container JSON logs & prunes cache/images âââ cacti/ # Cacti Network Monitoring Cleanup Scripts â âââ cacti_log.sh đĩ Truncates Cacti logs, Spine poller logs & cache âââ upload.bat # Windows batch script for automated git commit & push âââ .gitattributes # Enforces Unix LF line endings for shell scripts âââ LICENSE # MIT License âââ README.md # English Documentation âââ README.bn.md # āĻŦāĻžāĻāϞāĻž āĻĄāĻā§āĻŽā§āύā§āĻā§āĻļāύ (Bengali Documentation)
đ Complete Scripts Catalog
Explore all 9 scripts available in the repository
log_cleanup.sh
Advanced log cleaner that vacuums systemd journals, cleans apt cache, safely truncates active logs and container logs, and displays before/after disk stats.
Docker_log.sh
Safely truncates container JSON logs (*-json.log) without stopping containers. Prunes dangling images, build cache, and stopped containers.
cacti_log.sh
Safely truncates Cacti poller & Spine logs without breaking file permissions. Strictly isolates and preserves all .rrd performance graph files.
proxmox-cleanup.sh
Engineered exclusively for Proxmox VE hosts. Strictly isolates VM backup archives, templates, and ISO images from deletion while freeing gigabytes.
cleaning.sh
Multi-daemon cleaner. Cleans dedicated logs for Nginx, Apache2, MySQL/MariaDB, and Flussonic.
clean_up.sh
Standard cleanup script with specific checks for Nginx and RTMP streaming log directories, user trash directories, and APT archives.
clean_logs.sh
Minimalist bash script focused on clearing log files, deborphan packages, and APT caches without touching other services.
clean-logs.sh
Standard POSIX sh compatible log and cache cleaner for older or minimal Linux systems without bash-specific dependencies.
proxmox_clean.sh
Alternative Proxmox cleanup script for quick log truncation, trash emptying, and APT cache maintenance.
Automate with Cron (One-Liner Setup & Management)
Automate cleanup without manually opening or editing crontab files. Set, customize, verify, or remove in one command!
⥠Instant One-Liner
Downloads to /root/log_cleanup.sh and auto-adds to crontab:
sudo wget -O /root/log_cleanup.sh https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/ubuntu/log_cleanup.sh && sudo chmod +x /root/log_cleanup.sh (sudo crontab -l 2>/dev/null | grep -v "log_cleanup.sh"; echo "0 3 * * * /root/log_cleanup.sh >> /var/log/cleanup_cron.log 2>&1") | sudo crontab -
⥠Instant One-Liner
Downloads to /root/proxmox-cleanup.sh and auto-adds to crontab:
wget -O /root/proxmox-cleanup.sh https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/proxmox/proxmox-cleanup.sh && chmod +x /root/proxmox-cleanup.sh (crontab -l 2>/dev/null | grep -v "proxmox-cleanup.sh"; echo "0 3 * * * /root/proxmox-cleanup.sh >> /var/log/cleanup_cron.log 2>&1") | crontab -
⥠Instant One-Liner
Downloads to /root/Docker_log.sh and auto-adds to crontab:
sudo wget -O /root/Docker_log.sh https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/docker/Docker_log.sh && sudo chmod +x /root/Docker_log.sh (sudo crontab -l 2>/dev/null | grep -v "Docker_log.sh"; echo "30 3 * * 0 /root/Docker_log.sh >> /var/log/docker_cleanup_cron.log 2>&1") | sudo crontab -
⥠Instant One-Liner
Downloads to /root/cacti_log.sh and auto-adds to crontab:
sudo wget -O /root/cacti_log.sh https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/cacti/cacti_log.sh && sudo chmod +x /root/cacti_log.sh (sudo crontab -l 2>/dev/null | grep -v "cacti_log.sh"; echo "15 3 * * * /root/cacti_log.sh >> /var/log/cacti_cleanup_cron.log 2>&1") | sudo crontab -
Instantly remove scheduled cleanup jobs using sed:
sudo crontab -l | sed '/cleanup.*\.sh\|Docker_log\.sh\|cacti_log\.sh/d' | sudo crontab -
Create an isolated system cron file instead of editing root crontab:
echo "0 3 * * * root /root/log_cleanup.sh >> /var/log/cleanup_cron.log 2>&1" | sudo tee /etc/cron.d/system_cleanup
Check active cron entries and ensure daemon is enabled:
sudo crontab -l && sudo systemctl enable --now cron
âī¸ Interactive Crontab Line Builder
Customize your schedule, target script, and output log file:
Troubleshooting: Script Not Working or Line Ending Errors?
Fixing Windows CRLF ($'\r') on Linux servers
If you downloaded or edited the script on Windows and transferred it to Linux, you may encounter errors like:
â The 2-Step Solution (dos2unix):
sudo apt-get install -y dos2unix && dos2unix *.sh
sed -i 's/\r$//' *.sh
Frequently Asked Questions
Everything you need to know about safe system cleanup and space optimization.
How do I safely clean disk space on an Ubuntu or Debian server? âŧ
Run the one-liner command: curl -sSL https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/ubuntu/log_cleanup.sh | sudo bash. It vacuums systemd journals older than 7 days, safely truncates active logs to 0 bytes without deleting files, flushes APT caches, and frees gigabytes of space without crashing running services.
Does the Proxmox VE cleanup script delete VM backups or templates? âŧ
No, absolutely not. proxmox/proxmox-cleanup.sh strictly protects your VM & container backup archives (/var/lib/vz/dump/), OS ISO images (/var/lib/vz/template/iso/), and container templates (/var/lib/vz/template/cache/). Only host systemd journals, rotated logs, and APT caches are cleaned.
How does the Docker cleanup script work without container downtime? âŧ
docker/Docker_log.sh safely truncates active container JSON logs (*-json.log) to 0 bytes while containers are actively running. It also removes stopped containers, dangling untagged images, and build cache while leaving all persistent Docker volumes completely untouched.
How do I fix the "$'\r': command not found" error in Bash? âŧ
sudo apt-get install -y dos2unix && dos2unix *.sh
or use sed without installing anything:
sed -i 's/\r$//' *.sh
đ GitHub Star History
Thank you for supporting this open-source project!
Md. Sohag Rana
Network & IT Infrastructure Specialist
Sarker Net âĸ Lead Infrastructure & DevOps Specialist