Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Doesn't the Ampersand make commands run in the background?
- Date: Tue, 24 Oct 2006 19:38:17 +0900
- From: Romans Malinovskis <romaninsh@example.com>
- Subject: Re: [tlug] Doesn't the Ampersand make commands run in the background?
- References: <453DBA53.9050709@example.com>
I dutifully looked up the answer to my question before posting here, but what I read doesn't seem to be the case.
A web site said:
"The shell has the capacity to run multiple commands at one time, and can run commands in the background using the ampersand (&) after the command."
But on my system, when I try adding an ampersand after a command, I don't get the command prompt back. I have to either wait for wait for the command to finish it's task, or press [ctrl]+C.
Did I miss something? This seems very straight forward, so it's hard to guess at what could be wrong.
If you execute something like this:
app1 ; app2 &
then it might not happen.. You can try
( app1; app2 ) &
also - even if you type ampersand at the end, application is still using stdin/stdout (unless it specifically decides to detach those). That means you can't run "screen" or "mc" or "vi" in background, they would mess up your command line.
there are two tools which can help you. First you can use "screen" application. Check it's command line arguments, you can make it detach with the child process running and it will be hanging.
other way is to use "nohup". It's a standard tool, but might be missing from some distribution. It's idea is to detach stdin/stdout/ stderr from your terminal.
Another issue you might run into is - when you exit bash session (for example close terminal) child processes running in background will loose their terminal. Some (like "tail") don't care about that, while others (like vim) will die. Once again - screen and nohup helps.
Last tip - with bash you may run some program, hit Ctrl+Z (which suspends application) then type "bg" to resume it at the background. Some application will refuse to run in background. You can use "jobs" or "fg" to bring task back. You may specify number of task, see bash's help (type help jobs) for more info.
There is a good howto on this, which might be a bit too geeky:) - http://www.math.ucdavis.edu/~zjohnson/doc/Adv-Bash-Scr-HOWTO/
I hope this helps.
romans
- Follow-Ups:
- Re: [tlug] Doesn't the Ampersand make commands run in the background?
- From: Stuart Luppescu
- References:
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] PHP in Japan.
- Next by Date: Re: [tlug] Can I make a subdirectory of localhost behave like a root directory for a site?
- Previous by thread: Re: [tlug] Doesn t the Ampersand make commands run in the background?
- Next by thread: Re: [tlug] Doesn't the Ampersand make commands run in the background?
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links