Skip to content

Instantly share code, notes, and snippets.

@artyom
Created November 29, 2014 11:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artyom/06120b650a231e861766 to your computer and use it in GitHub Desktop.
Save artyom/06120b650a231e861766 to your computer and use it in GitHub Desktop.
Redirect script output to syslog from within script itself
#!/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