[USER@SERVER ~] sleep 3 &  5232 [USER@SERVER ~] + Done sleep 3 [USER@SERVER ~]
How do I /dev/null these two messages?:
 5232 + Done sleep 3
p.s.: so I need the output of the process, but not the mentioned two lines!
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
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.
Can't comment (yet) on @Gilles but it seems that
& disown also works in bash:
sleep 3 & disown
user@host:~$ read < <( sleep 10 & echo $! ) user@host:~$ echo $REPLY 28677
And you have hidden both the output and the PID. Note that you can still retrieve the PID from $REPLY