I've got a third-party Python script to run in background using nohup. And instead of piping the output to a file I'd like the output to be appended to the system log using logger. Added to that I need the error output to be logged using the priority "user.error" and the regular output "user.notice". This way I'm sure at least the errors pop up in the logs.

Running a simple command w/o nohup seems to work:

ls /tmp 1> >(logger --priority user.notice --tag myTag) 2> >(logger --priority user.error --tag myTag)

Running this /w nohup however yields unexpected results

nohup sh -c ls /tmp 1> >(logger --priority user.notice --tag myTag) 2> >(logger --priority user.error --tag myTag) &

The log will contain "nohup: ignoring input" and sometimes even empty entries.

Can somebody help me to write this command properly ?


You're redirecting the output of nohup to logger. To redirect the output of ls (or your python script), you can use command substitution:

nohup sh -c $(ls /tmp 1> >(logger --priority user.notice --tag myTag) 2> >(logger --priority user.error --tag myTag)) &
  • Thanks ! It works for *Ubuntu. But on Busybox I'm getting the error "-sh: command substitution: line 80: syntax error near unexpected token >' -sh: command substitution: line 80: ls /tmp 1> >(logger --priority user.notice --tag myTag) 2> >(logger --priority user.error --tag myTag))'". Any idea ? – Jan Goyvaerts Nov 13 '17 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.