Reputation: 693
I'm attempting to write a bash script that uses nohup and passes errors to rsyslog.
I've tried this command with different variations of the log variable (see below) but can't get the output passed to anything but a std txt file. I can't get it to pipe.
nohup imageprocessor.sh > "$LOG" &
Is it possible to pipe nohup output or do I need a different command.
A couple of variations of log that I have tried
LOG="|/usr/bin/logger -t workspaceworker -p LOCAL5.info &2"
or
LOG="|logtosyslog.sh"
or
LOG="logtosyslog.sh"
Upvotes: 3
Views: 3667
Reputation: 9685
Not directly. nohup will detach the child process, so piping the output of the nohup command isn't helpful. This is what you want:
nohup sh -c 'imageprocessor.sh | logger'
Upvotes: 1
Reputation: 4384
A way in bash
to redirect output to syslog is:
exec > >(logger -t myscript)
stdout
is then sent to logger
command
exec 2> >(logger -t myscript)
for stderr
Upvotes: 8