#!/bin/bash set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR [[ $EUID == 0 ]] # to deal with this bug until it\'s fixed # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=741521 # I just happened to notice it in my journal. str="dns: sendto() to \S\+ failed: Connection refused, failing over" if journalctl --since=-9m --unit=spamassassin | \ grep "$str" &>/dev/null; then echo "dns bug, restarting spamassassin" systemctl restart spamassassin fi