Can a Bourn Shell Script put itself in the background?
Barry Byrne
barry.byrne at wbtsystems.com
Thu Jun 4 14:42:25 UTC 2009
> From: owner-freebsd-questions at freebsd.org
> [mailto:owner-freebsd-questions at freebsd.org] On Behalf Of
> Martin McCormick
> I tried
>
> bg $$
>
> but $$ is the current process invoked just as $! is the process
> of a backgrounded process started by that shell.
>
> So, can I make a shell script background itself after
> starting?
>
> Right now, I remind my coworkers to append the & after the
> script name. the bg command expects a job number, not a process
> ID.
Martin,
If you mean you'd like to be able to put a script that is already running
into the background, then you could press CTRL-Z to suspend the process.
Then running 'jobs' will list the job id. Then 'bg jobnumber' (probably 1)
should put it into the background.
Cheers,
Barry
More information about the freebsd-questions
mailing list