Created
July 27, 2021 09:02
-
-
Save flisk/cde2d4aa0bbcc6fbdb403f949f53b864 to your computer and use it in GitHub Desktop.
Remove rsyslog and its log files from Debian systems not requiring rsyslog compatibility
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
#!/usr/bin/env bash | |
# | |
# remove-rsyslog -- remove rsyslog and its log files | |
# | |
# As of Debian 10, rsyslog exists mainly for backwards compatibility reasons, | |
# and it is not required for the base system to operate. If you do not require | |
# this backwards compatibility, you can use this script to remove rsyslog and | |
# all of its redundant log files from your system. | |
# | |
systemctl disable --now rsyslog.service | |
apt autoremove --purge --yes rsyslog | |
cd /var/log | |
kb_before="$(du -s . | awk '{print $1}')" | |
echo deleting logs from rsyslogd... | |
find /var/log \ | |
-maxdepth 1 \ | |
\( \ | |
-name 'auth.log*' -o \ | |
-name 'daemon.log*' -o \ | |
-name 'debug*' -o \ | |
-name 'kern.log*' -o \ | |
-name 'mail.err*' -o \ | |
-name 'mail.info*' -o \ | |
-name 'mail.log*' -o \ | |
-name 'mail.warn*' -o \ | |
-name 'messages*' -o \ | |
-name 'syslog*' -o \ | |
-name 'user*' \ | |
\) \ | |
-print \ | |
-delete | |
kb_after="$(du -s . | awk '{print $1}')" | |
kb_diff="$(( $kb_before - $kb_after ))" | |
printf 'before:\t%dk\nafter:\t%dk\ndiff:\t%dk\n' \ | |
"$kb_before" "$kb_after" "$kb_diff" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment