Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
[USER@SERVER ~] sleep 3 &
[1] 5232
[USER@SERVER ~] 
[1]+  Done                    sleep 3
[USER@SERVER ~] 

How do I /dev/null these two messages?:

[1] 5232
[1]+  Done                    sleep 3

p.s.: so I need the output of the process, but not the mentioned two lines!

share|improve this question
    
You only get those lines when you run it interactively. You don't if you run it from a script, for example. –  derobert Jan 25 '13 at 0:25

3 Answers 3

up vote 13 down vote accepted

It's not the program output, it's some useful shell information.

Anyway, those can be hided by using subshell and output redirection

( sleep 3 & ) > /dev/null 2>&1
share|improve this answer
1  
"2>/dev/null" is the good thing, i need the output from the process –  LanceBaynes Dec 10 '11 at 12:36
    
@LanceBaynes The process could also write something on stderr. –  Chris Down Dec 10 '11 at 18:45

In bash or zsh, you can call disown %1 to tell the shell to forget about the job. Then the shell won't print any message about that job, nor will it show it when you run jobs or ever send a SIGHUP to it. In zsh, starting the job with &! instead of & is equivalent to calling disown on it immediately.

share|improve this answer

Can't comment (yet) on @Gilles but it seems that & disown also works in bash:

sleep 3 & disown
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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