- journalctl -u $service.service --after-cursor=$(<$file) | \
- mail -s "$HOSTNAME: $service failure" $u@localhost
+ send_mail=true
+ fi
+ fi
+ if $send_mail; then
+ journalctl -u $service.service --after-cursor=$(<$file) | \
+ mail -s "$HOSTNAME: $service exit code: $code" $u@localhost
+ fi
+else
+ if [[ $file ]]; then
+ rm -f $file
+ if [[ $file == $c$errors ]]; then
+ echo | mail -s "$HOSTNAME: $service success" $u@localhost