diff options
author | Florian Pritz <bluewind@xinu.at> | 2020-03-05 08:44:32 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2020-03-05 08:44:32 +0100 |
commit | 779f9ac1d252a704bff612176e5e4ddaff32a940 (patch) | |
tree | 82de7892fc31319b454916147fc0fcd367374ceb /logandkeep-stdout-stderr | |
parent | ebc80494f4eb39b6119f931bcc9a4b05d7291f0f (diff) | |
download | bin-779f9ac1d252a704bff612176e5e4ddaff32a940.tar.gz bin-779f9ac1d252a704bff612176e5e4ddaff32a940.tar.xz |
Add logandkeep-stdout-stderr
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'logandkeep-stdout-stderr')
-rw-r--r-- | logandkeep-stdout-stderr | 12 |
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 |