I am new user to ubuntu...

Putting & and in the end is putting the application on background, but not really, it still gives me the output of the perl script in my command line even though it is running in background. So it becomes useless as I have to wait for full script to be completed.

Like :

output of perl..

So I still to have to wait till the perl script is executed, is there any way how such type of scripts can be made to run in background so that I don't have to wait?

I have already tried following:

command > test.txt //This generated emptyfile test.txt and all the output is still on command line instead of test.txt
command > /dev/null
command < /dev/null

None of them have been successful.

Please don't suggest to open new command line console, by doing CTRL+SHIFT+T or CTRL+ALT+T because I don't wanna do that, I wanna run the perl script in background while doing some work.

For other perl scripts, & is working fine but for this one, it isn't, is there any way around?

edit: Got the solution thanks to John1024 and Volker Siegel.

command 2> /dev/null &

2 Answers 2


Commands can produce output on stdout or stderr. The commands that you tried redirected only stdout. Under bash, you can redirect the output from both streams at once using:

command &>test.txt &


command &>/dev/null &

If you are using a POSIX shell, then you need to do the redirection in steps:

command >test.txt 2>&1 &

>test.txt redirects stdout to the file test.txt. Because stderr is file handle 2, the effect of 2>&1 is to redirect stderr to wherever stdout, denoted by &1 is currently going.

  • thanks it worked, i have been scratching my head since morning and googling this out! Thanks a lot! I can't vote your answer up as I don't have required reputation, so I am thanking you like this. Jul 19, 2014 at 23:24

It looks like the output is going to the error stream, stderr - so redirect that instead of stdout:

command 2> errors.txt

Or redirect both together to the same file:

command > errors.txt 2>&1

In case you want to know the whole thing - "jump into the rabbit hole" - see Illustrated Redirection Tutorial

See also nohup - it's useful if you want to keep the command running after closing the terminal:

nohup command

(man nohup for details)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .