Skip to content

Instantly share code, notes, and snippets.

@flisk
Created July 27, 2021 09:02
Show Gist options
  • Save flisk/cde2d4aa0bbcc6fbdb403f949f53b864 to your computer and use it in GitHub Desktop.
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
#!/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