Created
March 6, 2023 14:44
-
-
Save GreepTheSheep/eda27251ece1ca2966e59d5707650dd6 to your computer and use it in GitHub Desktop.
Script to cleanup Debian server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Delete old log files | |
sudo find /var/log -type f -name "*.gz" -exec rm -f {}; | |
sudo find /var/log -type f -name "*.log.*" -exec rm -f {} \; | |
sudo find /var/log -type f -name "*.1" -exec rm -f {} \; | |
# Delete temporary files | |
sudo rm -rf /tmp/* | |
# Delete unused dependencies | |
sudo apt-get autopurge -y > /dev/null | |
# Delete cache files | |
sudo apt-get clean -y > /dev/null | |
# Delete docker log files | |
sudo find /var/lib/docker/containers/ -type f -name "*-json.log" -exec rm -f {} \; | |
# Delete old unused container, images and volumes on docker | |
sudo docker container prune -f | |
sudo docker image prune -a -f | |
sudo docker system prune -a -f --volumes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment