Skip to content

Instantly share code, notes, and snippets.

@sudipidus
Last active May 27, 2019 14:20
Show Gist options
  • Save sudipidus/3832457df13a0b79a359b43fc63386fd to your computer and use it in GitHub Desktop.
Save sudipidus/3832457df13a0b79a359b43fc63386fd to your computer and use it in GitHub Desktop.
This script is to filter out the most recurring log messages. I faced an issue where syslog was rapidly increasing (35 GB) in a single day. I have /var/log mounted on root partition and this space usage was causing issue. Courtesy: https://askubuntu.com/a/515152/309358
for log in /var/log/{dmesg,syslog,kern.log}; do
echo "${log} :"
sed -e 's/\[[^]]\+\]//' -e 's/.*[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}//' ${log} \
| sort | uniq -c | sort -hr | head -10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment