User Tools

Site Tools


reducing_disk_usage_on_ubuntu

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
reducing_disk_usage_on_ubuntu [2024/08/15 00:07] – [Additional Tips] osoreducing_disk_usage_on_ubuntu [2024/12/04 04:14] (current) – [Additional Tips] oso
Line 102: Line 102:
  
 These methods should help you reclaim significant disk space on your Ubuntu system. These methods should help you reclaim significant disk space on your Ubuntu system.
 +
 +===== cronjob =====
 +
 +This cron job performs routine maintenance tasks to free up disk space and optimize the system on a low-storage VPS. It includes:
 +
 +   * Journal cleanup: Removes older system logs using journalctl --vacuum-time=7d.
 +   * Docker cleanup: Removes unused Docker objects (containers, images, networks, and volumes) with docker system prune -af --volumes.
 +   * APT cleanup: Frees space by removing unnecessary packages and cleaning up cached package files using apt autoremove -y and apt clean.
 +   * Kernel cleanup: Removes unused old Linux kernels to free significant space.
 +   * Log cleanup: Deletes compressed logs older than 7 days in /var/log.
 +   * Temporary files cleanup: Deletes unused temporary files older than 24 hours from /tmp and /var/tmp.
 +   * Snap cleanup: Removes old and unused versions of Snap packages.
 +
 +This script is executed every Friday at 2:00 PM (server time) to keep the VPS lean and functioning efficiently.
 +<code bash>
 +0 14 * * 5 journalctl --vacuum-time=7d && docker system prune -af --volumes && apt autoremove -y && apt clean && dpkg --list | grep linux-image | grep -v $(uname -r) | awk '{print $2}' | xargs apt-get -y purge && find /var/log -type f -name "*.gz" -mtime +7 -delete && find /tmp -type f -atime +1 -delete && find /var/tmp -type f -atime +1 -delete && snap list --all | awk '/disabled/{print $1, $3}' | while read snapname revision; do snap remove "$snapname" --revision="$revision"; done
 +</code>
  
reducing_disk_usage_on_ubuntu.1723680425.txt.gz · Last modified: 2024/10/17 21:42 (external edit)