Results 1 to 6 of 6
I run commands in the background usually with
`command &`
or
`nohup command &`
usually this hides output and allows me to continue to work on the console, or redirects ...
- 10-29-2009 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 20
Proper way to execute job in bg? redirect to /dev/null?
I run commands in the background usually with
`command &`
or
`nohup command &`
usually this hides output and allows me to continue to work on the console, or redirects output to nohup.out in the latter case
I was running a sh script I wrote using the former syntax, this sh script calls some other commands like svn update, phpunit, and rsync
svn outputs lines of text as it updates each external, phpunit outputs "." ( periods) and other output as it runs unit tests.
I'm sitting here working in vim and my background text is echoing to my console obscuring my current document I am editing. If I cntrl + c out of vim the output goes straight to my console
I am trying to post my bash log here but the forum says I cannot post "links" even though there are none
- 10-29-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
If you don't want any output, or to save it, you can redirect to /dev/null. However, you can also redirect stdout and stderr to files so that you can review the output after the process completes. In fact, if you nohup it, you can also tell nohup to output to another file name, or to /dev/null if you don't care and just want to send all the output to the bit bucket.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 10-29-2009 #3Just Joined!
- Join Date
- Oct 2009
- Posts
- 20
Thanks, When I typed & after the command what is that called though? because I do it that way all the time and never had the problem, maybe because these utilities are using stderror as their "standard output"?
the man command doesn't tell me anything about the & suffix. I googled for "amperstand suffix" which proved to be somewhat useful of a query.
When I do:
less build.php &
I get no output
but
echo foo &
does give me output?
- 10-29-2009 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
The ampersand (&) just tells the shell to run the process in the background. It does nothing with regard to redirection of I/O although some applications detect when they are running in the background and disable output for just that reason. However, this is not the default behavior of the system.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 10-29-2009 #5Just Joined!
- Join Date
- Oct 2009
- Posts
- 20
Thank you, that explains my observations
- 10-29-2009 #6Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
In case you didn't know, from the command line you can bring a background process back to the front with the shell command 'fg'. In fact, you can suspend a process, place it in the foreground, or if it is suspended you can place it in the background but active. You might want to review the bash commands fg, bg, and suspend for more information in the man pages.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote