Does nohup work across a pipe?

前端 未结 5 2012
悲哀的现实
悲哀的现实 2020-12-23 20:53

If I do

nohup cmd1 | cmd2 &

is that the same as

nohup \"cmd1 | cmd2\" &

?

I would like th

相关标签:
5条回答
  • 2020-12-23 20:55

    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.

    0 讨论(0)
  • 2020-12-23 21:02

    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.

    0 讨论(0)
  • 2020-12-23 21:06

    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
    
    0 讨论(0)
  • 2020-12-23 21:15
    nohup cmd1 | cmd2 &
    

    No, I have checked just now this is the as follows

    nohup: ignoring input and redirecting stderr to stdout
    
    0 讨论(0)
  • 2020-12-23 21:16

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

    echo "cmd1 | cmd2" > nohupScript.sh
    nohup nohupScript.sh &
    
    0 讨论(0)
提交回复
热议问题