Skip to content

sohag1192/System-Cleanup-Script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


🧹 System Cleanup & Space Optimization

📖 Overview

This repository contains shell scripts to automate system cleanup and disk space optimization.
It helps free up space by cleaning logs, caches, orphaned packages, and temporary files across Ubuntu/Proxmox servers.


⚙️ Features

  • Truncate all log files under /var/log (excluding wtmp and btmp).
  • Delete rotated/compressed logs (*.gz, *.1, etc.).
  • Vacuum systemd journal logs older than 7 days.
  • Clear Nginx and RTMP logs.
  • Clean APT cache and remove orphaned packages.
  • Delete trash and manual pages.
  • Show disk usage after cleanup.

🚀 Usage

1. Download the script

wget -O log_cleanup.sh https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/log_cleanup.sh
chmod +x log_cleanup.sh

2. Run manually

sudo ./log_cleanup.sh

3. Automate with cron

Edit crontab:

crontab -e

Add this line to run daily at 3:00 AM:

0 3 * * * /root/log_cleanup.sh >> /root/log_cleanup.log 2>&1

📂 Scripts Included

  • clean-logs.sh – Apache2, Nginx, and Ubuntu cache cleanup.
  • clean.sh – General cleanup script.
  • clean_up.sh – Renamed version of clean.sh.
  • log_cleanup.sh – Advanced Ubuntu log cleaner with disk usage report.

🛡️ Notes

  • Safe for production servers, but always review before deploying.
  • Run periodically to maintain optimal performance.
  • Requires deborphan for orphaned package removal.

# Ubuntu Log Cleaner
wget -O log_cleanup.sh https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/log_cleanup.sh

# Apache2/Nginx + Ubuntu cache cleanup
wget -O clean-logs.sh https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/clean-logs.sh

# General cleanup script
wget -O clean_up.sh https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/clean_up.sh

# Proxmox cleanup script
wget -O proxmox-cleanup.sh https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/proxmox-cleanup.sh

# Alternate Proxmox cleanup script
wget -O proxmox_clean.sh https://raw.githubusercontent.com/sohag1192/System-Cleanup-Script/main/proxmox_clean.sh

📂 Scripts included

  • log_cleanup.sh – Advanced Ubuntu log cleaner with disk usage report
  • clean-logs.sh – Apache2, Nginx, and Ubuntu cache cleanup
  • clean_up.sh – General cleanup script (renamed from clean.sh)
  • proxmox-cleanup.sh – Proxmox‑specific cleanup with cache/log removal
  • proxmox_clean.sh – Alternate Proxmox cleanup script

⚡ Quick usage

  1. Run chmod +x scriptname.sh after download.
  2. Execute with sudo ./scriptname.sh.
  3. (Optional) Add to cron for scheduled cleanup.

This way you’ll have all log cleanup scripts locally, ready to run or customi


👤 Maintainer

Md. Sohag Rana
Network & IT Infrastructure Manager, Sarker Net
📧 Email: sohag1192@gmail.com
💬 Telegram: sohag1192


About

🧼 Script by Sohag — System Cleanup & Space Optimization

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages