📖 Overview
Over time, Linux and Proxmox servers accumulate gigabytes of disk bloat: systemd journals, rotated log files (.gz, .1), APT package archives, and trash. If left unchecked, root partitions fill up, leading to crashed databases and stalled services.
This repository provides battle-tested shell scripts organized into separate folders for Ubuntu / Debian and Proxmox VE. Every script safely truncates log files instead of removing them, preventing broken service file descriptors.
🏆 Which Script is the Best? (Recommended)
| Platform / Service |
Best Script |
Why It's the Best? |
| Ubuntu / Debian |
ubuntu/log_cleanup.sh |
🌟 Most balanced & safe: Cleans systemd journal logs (journalctl), protects security logs (wtmp/btmp), truncates without crashing services, and does not remove essential system tools. |
| Proxmox VE |
proxmox/proxmox-cleanup.sh |
🌟 100% Storage Safe: Vacuums journals, truncates logs and APT caches while strictly protecting Backups (/var/lib/vz/dump/), ISO Images (/var/lib/vz/template/iso/), and CT Templates (/var/lib/vz/template/cache/). |
| Docker Engine |
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 preserving data volumes. |
| Cacti Monitoring |
cacti/cacti_log.sh |
🌵 Safe Cacti & Spine Cleaner: Safely truncates cacti.log and spine.log without breaking file permissions, deletes rotated archives, cleans cache, and strictly protects all .rrd performance metric graphs. |
📁 Repository Structure
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)
⚡ Quick One-Liner Installation & Execution
1. For Ubuntu / Debian (Recommended: log_cleanup.sh)
Direct Run (One-liner):
curl -sSL https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/ubuntu/log_cleanup.sh | sudo bash
Download to /root/ & Run:
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 /root/log_cleanup.sh
2. For Proxmox VE (Recommended: proxmox-cleanup.sh)
Direct Run (One-liner):
curl -sSL https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/proxmox/proxmox-cleanup.sh | bash
Download to /root/ & Run:
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
/root/proxmox-cleanup.sh
[!IMPORTANT]
Proxmox Storage Safety: proxmox/proxmox-cleanup.sh strictly protects your Backups, ISO Images, and Container (CT) Templates. Not a single VM or container image is removed!
3. For Docker Environment (Docker_log.sh)
Direct Run (One-liner):
curl -sSL https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/docker/Docker_log.sh | sudo bash
Download to /root/ & Run:
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 /root/Docker_log.sh
4. For Cacti Monitoring Server (cacti_log.sh)
Direct Run (One-liner):
curl -sSL https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/cacti/cacti_log.sh | sudo bash
Download to /root/ & Run:
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 /root/cacti_log.sh
[!IMPORTANT]
RRA / Graph Data Safety: cacti/cacti_log.sh strictly protects your .rrd graph files and rra/ directories. Your historical bandwidth and device metrics are 100% safe!
5. 📦 Download Complete Scripts Bundle (ZIP Archive)
If you prefer to download all scripts at once as a single .zip archive rather than individual files:
Direct Browser Download:
Download & Extract via Linux Terminal:
# Using wget:
wget -O System-Cleanup-Script.zip https://github.com/sohag1192/System-Cleanup-Script/archive/refs/heads/main.zip
unzip System-Cleanup-Script.zip
cd System-Cleanup-Script-main
# Or using curl:
curl -sSL -o System-Cleanup-Script.zip https://github.com/sohag1192/System-Cleanup-Script/archive/refs/heads/main.zip
unzip System-Cleanup-Script.zip
cd System-Cleanup-Script-main
# Make all scripts executable:
chmod +x ubuntu/*.sh proxmox/*.sh docker/*.sh cacti/*.sh
# Run any cleanup script (e.g. recommended Ubuntu log cleaner):
sudo ./ubuntu/log_cleanup.sh
📊 Comprehensive Feature Comparison
| 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 |
❌ |
❌ |
❌ |
✅ (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) |
❌ |
⏰ Automate with Cron (One-Liner Setup & Management)
You can automate cleanup without manually opening or editing crontab files by first downloading the script to /root/ and then running the one-liner command:
⚡ Option 1: Instant One-Liner (No editor required - Recommended)
For Ubuntu / Debian (Daily at 3:00 AM):
# 1. Download to /root/log_cleanup.sh
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
# 2. Add to crontab in one command
(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 -
For Proxmox VE (Daily at 3:00 AM):
# 1. Download to /root/proxmox-cleanup.sh
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
# 2. Add to crontab in one command
(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 -
For Docker Host (Weekly on Sunday at 3:30 AM):
# 1. Download to /root/Docker_log.sh
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
# 2. Add to crontab in one command
(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 -
For Cacti Monitoring Server (Daily at 3:15 AM):