summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2020-03-05 08:44:32 +0100
committerFlorian Pritz <bluewind@xinu.at>2020-03-05 08:44:32 +0100
commit779f9ac1d252a704bff612176e5e4ddaff32a940 (patch)
tree82de7892fc31319b454916147fc0fcd367374ceb
parentebc80494f4eb39b6119f931bcc9a4b05d7291f0f (diff)
downloadbin-779f9ac1d252a704bff612176e5e4ddaff32a940.tar.gz
bin-779f9ac1d252a704bff612176e5e4ddaff32a940.tar.xz
Add logandkeep-stdout-stderr
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--logandkeep-stdout-stderr12
1 files changed, 12 insertions, 0 deletions
diff --git a/logandkeep-stdout-stderr b/logandkeep-stdout-stderr
new file mode 100644
index 0000000..7e8c09f
--- /dev/null
+++ b/logandkeep-stdout-stderr
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# Mostly a snippet that you can copy to other scripts
+
+# Log stdout/stderr, but also keep them separate for use in e.g. crontab
+# (redirect stdout > /dev/null without losing stderr)
+exec > >(tee >(logger -t "${0##*/}"))
+exec 2> >(tee /dev/stderr | logger -t "${0##*/}")
+
+# demo
+echo "stdout message"
+echo "stderr message" >&2