I'm running this command:

$ nohup command > foo.out 2> foo.err < /dev/null &

My problem is that even though nohup makes my command run in the background, it prints out something like this to my terminal:

[1] 27918

How do I make it not output the job number? I just want it to do it in the background without telling me anything. On Mac OS X, that's exactly what happens, so I'm a little annoyed that it works differently on Ubuntu...

Thanks for the help!

link|improve this question
2  
The [1] 27918 is coming from the & not the nohup – Majenko Mar 1 '11 at 8:50
Thanks Matt, that did it. Now how do I close this question... – hora Mar 1 '11 at 8:53
The way to do that is mark an answer as accepted using the checkmark next to it. – Dennis Williamson Mar 1 '11 at 10:06
See superuser.com/faq section "How do I ask questions" – grawity Mar 1 '11 at 10:10
feedback

2 Answers

Job information is displayed by your shell, not nohup.

You could try this alternative:

(yourcommand&)

( spawns a subshell, which handles job control differently.

(I have nh() { ("$@" &); } in my ~/.bashrc, so I can type nh command to do the same thing.)

Another, different way:

setsid yourcommand

Edit: It seems that (setsid yourcommand &) is the best combination, since it detaches from the tty and works equally in interactive and script modes.

link|improve this answer
(command &) worked for me where I was having ioctl error with nohup. – Shahzada Hatim May 10 at 12:22
feedback

The [1] 27918 is coming from the & not the nohup.

Put the command you want to run in the background inside a script file:

#!/bin/sh
/path/to/command & >/dev/null 2>/dev/null

and then call that with nohup

nohup sh /path/to/my/script > foo.out 2> foo.err < /dev/null

The output of & is then redirected to /dev/null inside the script.

link|improve this answer
& is only a command terminator, it doesn't output anything and you cannot redirect it. In interactive mode, the job line is printed by the shell; in non-interactive (including scripts), it remains quiet. Your inner redirects apply to output of the command itself, and I do not think the outer redirects will override them. – grawity Mar 1 '11 at 9:05
feedback

Your Answer

 
or
required, but never shown

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