iankelling.org
/
git
/
log-quiet
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
af60b67
)
fix stuck on email error
author
Ian Kelling
<iank@fsf.org>
Thu, 10 Nov 2022 19:46:41 +0000
(14:46 -0500)
committer
Ian Kelling
<iank@fsf.org>
Thu, 10 Nov 2022 19:46:41 +0000
(14:46 -0500)
README
patch
|
blob
|
history
sysd-mail-once
patch
|
blob
|
history
diff --git
a/README
b/README
index e463d691de06440d27c471939e1153cfd28c7a18..e7fab7e6b24e69cfd7d8e012374e8ef4d2dbb48f 100644
(file)
--- a/
README
+++ b/
README
@@
-1,8
+1,5
@@
Log output, conditionally email or print it
Log output, conditionally email or print it
-Warning: with sysd-log-once, I've found the mail command to block for
-several seconds at least.
-
The main documentation is availiable via --help and near the top of the
bash script files which sit next to this file.
The main documentation is availiable via --help and near the top of the
bash script files which sit next to this file.
diff --git
a/sysd-mail-once
b/sysd-mail-once
index 2f7f4d5d9efd035d7803d623bb946090f4597be7..b1a67b881cee88388d64ff0e31cda81d24de96f7 100755
(executable)
--- a/
sysd-mail-once
+++ b/
sysd-mail-once
@@
-24,7
+24,7
@@
case "$1" in
-h|--help)
cat <<EOF
Usage: sysd-mail-once [-t TO_ADDRESS] [-ERRORS] SERVICE COMMAND [ARGS...]
-h|--help)
cat <<EOF
Usage: sysd-mail-once [-t TO_ADDRESS] [-ERRORS] SERVICE COMMAND [ARGS...]
-For systemd timers, email on repeated failure & success after failure.
+For systemd timers, email
(with exim)
on repeated failure & success after failure.
In the service triggered by the timer, prepend this script to the ExecStart.
The email will contain the service's logs for the last ERRORS runs.
In the service triggered by the timer, prepend this script to the ExecStart.
The email will contain the service's logs for the last ERRORS runs.
@@
-81,14
+81,24
@@
if (( code )); then
fi
fi
if $send_mail; then
fi
fi
if $send_mail; then
- journalctl -u $service.service --after-cursor=$(<$file) | \
- mail -s "$HOSTNAME: $service exit code: $code" "$to"
+ exim -odf -t <<EOF
+To: $to
+From: $USER@$(hostname -f)
+Subject: $HOSTNAME: $service exit code: $code
+
+$(journalctl -u $service.service --after-cursor=$(<$file))
+EOF
fi
else
if [[ $file ]]; then
rm -f $file
if [[ $file == $c$errors ]]; then
fi
else
if [[ $file ]]; then
rm -f $file
if [[ $file == $c$errors ]]; then
- echo | mail -s "$HOSTNAME: $service success" "$to"
+ exim -odf -t <<EOF
+To: $to
+From: $USER@$(hostname -f)
+Subject: $HOSTNAME: $service success
+
+EOF
fi
fi
fi
fi
fi
fi