44 lines
892 B
Bash
44 lines
892 B
Bash
#!/bin/bash
|
|
|
|
# Prune container images
|
|
if [ -x "$(command -v docker)" ]; then
|
|
echo "Pruning using Docker"
|
|
sudo docker image prune -af
|
|
|
|
elif [ -x "$(command -v podman)" ]; then
|
|
echo "Pruning using Podman"
|
|
sudo podman image prune -af
|
|
|
|
else
|
|
echo "No container images to prune"
|
|
fi
|
|
|
|
|
|
# Remove all disabled snaps
|
|
if [ -x "$(command -v snap)" ]; then
|
|
echo "Remove all deactivated snaps"
|
|
sudo snap list --all | \
|
|
awk '/disabled/{print $1, $3}' | \
|
|
while read snapname revision; do \
|
|
sudo snap remove "$snapname" --revision="$revision";
|
|
done
|
|
else
|
|
echo "No snaps found"
|
|
fi
|
|
|
|
|
|
# Flush and rotate all logs
|
|
if [ -x "$(command -v journalctl)" ]; then
|
|
echo "Vacuuming logs using journalctl"
|
|
sudo journalctl \
|
|
--flush \
|
|
--rotate \
|
|
--vacuum-time=1s
|
|
else
|
|
echo "JournalCTL not found"
|
|
fi
|
|
|
|
# remove zipped logs
|
|
echo "Delete zipped logs"
|
|
sudo rm -rf /var/log/*.gz
|