Created
November 29, 2014 11:37
-
-
Save artyom/06120b650a231e861766 to your computer and use it in GitHub Desktop.
Redirect script output to syslog from within script itself
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -eu | |
LOGPIPE=/tmp/logpipe.$$ | |
mkfifo $LOGPIPE | |
logger -t "$0.$$" -f $LOGPIPE & | |
exec 1>$LOGPIPE | |
exec 2>&1 | |
rm -f $LOGPIPE | |
echo "hello on stdout" | |
echo "hello on stderr" >&2 | |
exec sleep 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment