Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

if I make

sleep 2 &

this command run in backgroung, and in two seconds, I get "Done".
How I can avoid seeing the "Done" message ?

share|improve this question

migrated from stackoverflow.com Jul 4 '11 at 3:45

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 10 down vote accepted

Run the command in a subshell:

(sleep 2 &)
share|improve this answer

Execute the shell built-in:

$ set +m

This works by turning off "monitor mode" so the shell doesn't report terminating background jobs.

Although running the command in a subshell like:

$ (sleep 2&)

...will also disable the message, the only reason it works is because monitor mode is enabled by default only for interactive shells. That is, the subshell avoid the message by running an extra shell that has an automatic "set +m".

share|improve this answer
3  
One should note, that this output is not performed by the sleep. Its the bash shell that just informs you about the finished background job. –  flolo Jul 4 '11 at 3:34

I'd like to clarify the two earlier answers. If what you want is never to see the Done message from any commands in your shell, set +m is the way to go. Just put it in your .profile and/or .bashrc and be done. Note however, that if you type this:

set +m
sleep 2 &
set -m

and the sleep ends after the final set -m, you will still get the done message.

If you want to disable the message for a single command invocation, the subshell technique (sleep 2 &) is the way to go.

In all honesty, I only knew about set +m, so +1 to Wooble for enlightening me. However, it is worth noting that which of the two solutions you want depends on what you are trying to do.

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.