Re: how start a detached process in bash?
- From: Stephane CHAZELAS <this.address@xxxxxxxxxx>
- Date: Thu, 2 Mar 2006 20:00:58 +0000
2006-03-03, 06:34(+11), Grant:
Hi there,[...]
When I run 'script &' on command line I get the pid message and
the prompt back. This doesn't happen when I run 'script &' inside
a bash script, instead I get a command prompt but the bash as well
its 'script' are both running.
man bash doesn't have the word detach, so how do I start a detached
process (script &) from within a script?
If you want to detach it from bash, simply use disown:
disown %1
will detach the job number 1 (assuming you started it in
background).
Or start it as:
(cmd ...&)
If you want do detach it from the terminal (not make it a
login session bound process), either run it through at(1):
at now << EOF
cmd ...
EOF
or use start-stop-daemon if available on your system.
or use setsid(1) if available on your system:
setsid sh -c 'cd / && cmd ... & :' > /dev/null 2>&1 < /dev/null
--
Stéphane
.
- Follow-Ups:
- Re: how start a detached process in bash?
- From: Grant
- Re: how start a detached process in bash?
- References:
- how start a detached process in bash?
- From: Grant
- how start a detached process in bash?
- Prev by Date: Re: how start a detached process in bash?
- Next by Date: Re: how start a detached process in bash?
- Previous by thread: Re: how start a detached process in bash?
- Next by thread: Re: how start a detached process in bash?
- Index(es):