-1

I can redirect output to logger like this:

nohup bin/mytask | logger

But the process hangs, and my cursor doesn't return to the terminal after the command is sent. (I would have to return to terminal with ctrl c and I don't want to quit the process.

So I try this command:

nohup bin/mytask & | logger

But I get this error:

bash: syntax error near unexpected token|'`

How can redirect the output to the logger and then return tom the terminal?

  • 1
    There's a contradiction in this question in the form of a process that is "done" that the questioner does not want to quit because it is still running. It cannot be both done and still running. – JdeBP Sep 9 '18 at 8:17
  • Fixed the contextual error ... I changed it to "But the process hangs, and my cursor doesn't return to the terminal after the command is sent." – AAA Sep 9 '18 at 23:14
2
nohup bin/mytask | logger &

& is a command separator, just like ; and |, and you have to background a whole pipeline, not just one command in it.

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.