mike
mike

Reputation: 37

Why nohup outputs process id?

When I'm running command nohup sh script.sh & in Terminal I have the following output: [1] 42603 appending output to nohup.out. Where 42603 is process id of this command, but I don't want to see it. What can I do?

P.S. I'm running OSX Capitan, version 10.11.6

Upvotes: 1

Views: 165

Answers (2)

Grady Player
Grady Player

Reputation: 14549

something like this will mute that one line and will keep the script.sh connected to stdout

nohup sh script.sh & | grep -v nohup.out

if it is outputting that thing to stderr you will need to redirect to stdout

nohup sh script.sh 2>&1 & | grep -v nohup.out maybe the order is wrong there, my shell scripting syntax is usually wrong

Upvotes: 1

K. Biermann
K. Biermann

Reputation: 1318

You can run nohup in a subshell and redirect the subshell's output to /dev/null like this: (nohup sh script.sh &) >/dev/null (note that this will also hide any output from sh script.sh)

Upvotes: 1

Related Questions