diff options
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 |