As an example:
I have working shell script which starts up weblogic (which will continue to run) and then do deployment
At the end I bring background process back to foreground, so that shell script does not exit (Exited with code 0)
#!/bin/bash
set -m
startWebLogic.sh &
# create resources in weblogic
# deploy war
# ...
jobs -l
fg %1
I had to use set -m
, to allow job control, but I also found it is not cleaniest way to use it in non-interactive shells.
Is there a better way to handle it?
Best Answer
As far as I understand your question you are looking for
wait
:It does not "bring the process to foreground". But it does wait until weblogic returns. So the shell script does not exit until weblogic exits. Which is the effect you achieved with
fg %1
.from
help wait
: