2023-08-06 22:15:06 +02:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
2024-02-24 14:31:19 +01:00
|
|
|
|
2023-08-06 22:15:06 +02:00
|
|
|
# purge memory
|
|
|
|
free -h
|
|
|
|
echo "clearing memory"
|
|
|
|
sudo sync
|
|
|
|
sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
|
|
|
|
free -h
|
|
|
|
|
|
|
|
|
|
|
|
# clear logs
|
2024-02-24 14:31:19 +01:00
|
|
|
echo "clearing logs"
|
2023-08-06 22:15:06 +02:00
|
|
|
sudo du -hs /var/log
|
2024-02-24 14:31:19 +01:00
|
|
|
sudo rm -rf /var/log/**.gz
|
|
|
|
sudo rm -rf /var/log/**.[1-9]
|
|
|
|
sudo du -hs /var/lib/docker/containers/*/*-json.log
|
|
|
|
sudo rm -rf /var/lib/docker/containers/*/*-json.log
|
2023-08-06 22:15:06 +02:00
|
|
|
|
2024-02-24 14:31:19 +01:00
|
|
|
echo "clearing apache logs"
|
2023-08-06 22:15:06 +02:00
|
|
|
sudo du -hs /etc/apache2/logs
|
|
|
|
sudo find /etc/apache2/logs -type f -delete
|
|
|
|
sudo du -hs /etc/apache2/logs
|
|
|
|
|
2024-02-24 14:31:19 +01:00
|
|
|
echo "clearing nginx logs"
|
|
|
|
sudo du -hs /etc/nginx/logs
|
|
|
|
sudo find /etc/nginx/logs -type f -delete
|
|
|
|
sudo du -hs /etc/nginx/logs
|
|
|
|
|
|
|
|
# remove temp things
|
|
|
|
sudo du -hs /var/lib/systemd/coredump/
|
|
|
|
sudo rm -rf /var/lib/systemd/coredump/*
|
|
|
|
sudo rm -rf ~/.xsession-errors*
|
|
|
|
sudo rm -rf ~/.config/doublecmd/doublecmd.err
|
|
|
|
sudo rm -rf ~/.mozilla/firefox/Crash\ Reports/
|
|
|
|
|
2023-08-06 22:15:06 +02:00
|
|
|
|
|
|
|
# empty trash
|
2024-02-24 14:31:19 +01:00
|
|
|
sudo rm -rf ~/.local/share/Trash/*
|
2023-08-06 22:15:06 +02:00
|
|
|
sudo rm -rf /root/.local/share/Trash/*
|
2024-02-24 14:31:19 +01:00
|
|
|
sudo rm -rf /.Trash-1000
|
2023-08-06 22:15:06 +02:00
|
|
|
sudo rm -rf /[A-Z]*/.Trash-1000
|
|
|
|
sudo rm -rf /media/*/.Trash-1000
|
|
|
|
sudo rm -rf /media/*/*/.Trash-1000
|
|
|
|
sudo rm -rf /mnt/*/.Trash-1000
|
|
|
|
sudo rm -rf /mnt/*/*/.Trash-1000
|
|
|
|
# rm -rf /_servers/*/.Trash-1000
|
|
|
|
|
2024-02-24 14:31:19 +01:00
|
|
|
|
|
|
|
# remove nohup
|
|
|
|
sudo rm -rf /home/*/nohup.out
|
|
|
|
|
|
|
|
|
|
|
|
# prune unused docker images
|
|
|
|
sudo docker system prune -a -f
|
|
|
|
|
|
|
|
|
2023-08-06 22:15:06 +02:00
|
|
|
# vacuum firefox
|
|
|
|
kill -9 firefox
|
|
|
|
cd ~/.mozilla/firefox/dym/
|
2024-02-24 14:31:19 +01:00
|
|
|
du -hs ~/.mozilla/firefox/dym/
|
2023-08-06 22:15:06 +02:00
|
|
|
find -maxdepth 1 -type f \
|
|
|
|
| xargs file -F "" \
|
|
|
|
| awk '/SQLite/{print $1}' \
|
|
|
|
| xargs -n 1 -I FILE bash -c \
|
|
|
|
'echo Vacuuming $1; sqlite3 $1 "vacuum;"' \
|
|
|
|
bash FILE
|
2024-02-24 14:31:19 +01:00
|
|
|
du -hs ~/.mozilla/firefox/dym/
|
|
|
|
|
2023-08-06 22:15:06 +02:00
|
|
|
|
2024-02-24 14:31:19 +01:00
|
|
|
# Cleaning the old kernels
|
|
|
|
# dpkg-query -l | grep 'linux-im*'
|
|
|
|
# #dpkg-query -l | grep linux-im* | awk '{print $2}'
|
2023-08-06 22:15:06 +02:00
|
|
|
|
2024-02-24 14:31:19 +01:00
|
|
|
# sudo apt-get purge -y $(dpkg -l 'linux-*' \
|
|
|
|
# | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | head -n -1) \
|
|
|
|
# --assume-yes
|
2023-08-06 22:15:06 +02:00
|
|
|
|
2024-02-24 14:31:19 +01:00
|
|
|
# sudo apt-get install -y linux-headers-`uname -r \
|
|
|
|
# |cut -d'-' -f3`-`uname -r \
|
|
|
|
# |cut -d'-' -f4`
|