Tuesday, May 7, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 11145  / 3 Years ago, wed, june 23, 2021, 5:33:01

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..
..
..
Done.


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 &


More From » command-line

 Answers
0

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 &


Or



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.


[#24066] Thursday, June 24, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cheeturage

Total Points: 432
Total Questions: 111
Total Answers: 115

Location: Bahrain
Member since Tue, Mar 1, 2022
2 Years ago
cheeturage questions
Sat, Dec 4, 21, 02:22, 2 Years ago
Mon, Jan 2, 23, 22:39, 1 Year ago
Sun, Sep 12, 21, 03:21, 3 Years ago
;