Does nohup work across a pipe?

You could start your pipe in a screen session. Keystroke Ctrl-a and then d will detach the screen session from your terminal. You can then safely exit your terminal; the pipe will continue to run. Use screen -r to reconnect to the session again.


No, you need to add the nohup to the commands separately.

Something like this is recommended:

nohup sh -c "cmd1 | cmd2" &

Or alternatively:

nohup $SHELL <<EOF &
cmd1 | cmd2
EOF

As an alternative to nohup, I recommend

( cmd1 | cmd2 ) > logfile < /dev/null 2>&1 &

By rerouting stdin, stdout, and sterr from the terminal, this achieves much the same effect as nohup with a syntax that I, at least, prefer.


You always can create a script file and run it with nohup:

echo "cmd1 | cmd2" > nohupScript.sh
nohup nohupScript.sh &

Tags:

Linux

Bash