-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem_cleaner.sh
executable file
·39 lines (31 loc) · 970 Bytes
/
system_cleaner.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Removes old revisions of snaps and clean apt cache
set -eu
echo "Cache apt..."
sudo du -sh /var/cache/apt
echo "Cleaning with autoremove, autoclean and clean"
sudo apt-get -y autoremove
sudo apt-get -y autoremove --purge
sudo apt-get -y autoclean
sudo apt-get -y clean
echo "Cleaning journal"
journalctl --disk-usage
journalctl --vacuum-time=7d
echo "Before cleaning"
du -h /var/lib/snapd/snaps
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
echo "After cleaning..."
du -h /var/lib/snapd/snaps
echo "thumbnails"
du -sh ~/.cache/thumbnails
rm -rf ~/.cache/thumbnails/*
echo "Cleaning Docker system this is gonig to ask you for confirmation..."
docker rmi $(docker images)
docker image prune -a
docker container prune
docker volume prune
docker network prune --filter "until=72h"
docker rm $(docker ps -qa --no-trunc --filter "status=exited")