How to hide shell process information when starting background process?

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.


Try:

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

Tags:

Bash

Ubuntu