Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The command to launch a program, say evince, from bash shell in background is

evince &

But what if I want to open some file with evince in background? Nor evince myfile.pdf & neither evince & myfile.pdf work as expected: the first outputs something like [2] 5356 but in the next line the shell returns locked; the second opens an empty istance of evince.

So, what syntax can I use?

share|improve this question
The first one should work. Sometimes you don't get a prompt printed after starting a background process (seems to be a bug). Just press enter and the prompt should appear, if not then this is also a bug (though somewhat more serious). – Graeme Apr 10 '14 at 18:24
Yes the prompt appears if I press enter one more time. – BowPark Apr 21 '14 at 18:08
up vote 4 down vote accepted

Sometimes, when you start a program, it prints out some message. If you start it in background, the program may lock up until you bring it back to the foreground so that it can display its message. The solution is to redirect stdout and stderr so that the program can continue running in the background. One way to do this is:

evince myfile.pdf >~/evince.errs 2>&1 &

The above creates a file in your home directory with whatever message evince wanted to display.

If you are convinced that evince's messages are unimportant, you can discard them without creating a file:

evince myfile.pdf >/dev/null 2>&1 &

After running either of the above commands, the shell should produce a message like [1] 1234 and then a shell prompt should appear. As Graeme suggests, if the shell prompt does not appear, try pressing enter again.

share|improve this answer
Background commands still have their output printed on the shell. All that redirection should not be necessary. – Darkhogg Apr 10 '14 at 23:52
Also, instead of >some_file 2>&1 you can redirect both stdout and stderr at once using &>some_file. – Darkhogg Apr 10 '14 at 23:53
Thank you, there where some message errors and so they disappeared, but the prompt doesn't appear. – BowPark Apr 21 '14 at 18:05
@BowPark As a test, after starting the background job and when the prompt doesn't appear, try typing date and pressing enter. If you see the date output, that means that the prompt actually did return but, for some reason, it is not visible. – John1024 Apr 21 '14 at 22:52
You're right, the output is correct. – BowPark Apr 21 '14 at 22:59
evince myfile.pdf



That opens the program, suspends it, then backgrounds it.


( evince myfile.pdf ) &

Would open evince in a (subshell) and backgrounds the (subshell). It's a little weird that simply:

evince myfile.pdf &

doesn't work though because it does for me.

You might want to:

echo $-

And check your job control parameters. I recommend:

set -b

if you're not already using it. Do:

man set

for more info. Or see my other answer here.

share|improve this answer
I tried with -b but the shell behaves as before, like in all the other solutions. Thank you anyway! Maybe my shell has a bug. When I launch a program in backgroud, if then i press Enter the prompt appears, like written in a comment to my question. – BowPark Apr 21 '14 at 18:03

Your Answer


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.