I am writing a ksh script, in which I want to start weblogic server in background and return to underlying script immediately(continue to execute the script) like this:

nohup path_to_domain_bin/startWebLogic.sh>/dev/null < /dev/null 2>&1

but my script hangs up after the nohup command, what's the right way to do what I want?

please note, I want to get rid of nohup.out.

I am running it on AIX 7.1

1 Answer 1


Start the command as a background task, with & at the end:

nohup path_to_domain_bin/startWebLogic.sh>/dev/null < /dev/null 2>&1 &

The output redirections are not helping much, as nohup redirects the output anyway, as you have noticed. To get rid of that, skip nohup and do what it does (rather, the essential part of it) in the script yourself:

trap "" 1                            # catch hangup signal
path_to_domain_bin/startWebLogic.sh>/dev/null < /dev/null 2>&1 &

But I have an uneasy feeling with completely discarding the information that calling the program may give you. This way, you wouldn't even get an error if the called pathname is wrong!

I usually append such output to a log file, including a bit of additional information, like this:

 trap "" 1                            # catch hangup signal
 exec 1>> $LOGFILE                    # redirect output a bit more readably
 exec 2>> $LOGFILE
 exec < /dev/null

 path_to_domain_bin/startWebLogic.sh &
 date "+%Y%m%d:%H%M%S weblogic started with PID $!"

The exec redirects are a bit more readable, which pays off in a script IMO; besides, the date call gets redirected, too. Running this in a subshell (...) makes sure the effect of the redirects is kept to this part of the script.

  • Thank you sir! Can u explain a bit about the "&" at the end of the nohup command? And as weblogic has it's own log, why we need weblogic_start.log? As how I understand it, information about weblogic start process will goes to domain logs Commented Jul 22, 2014 at 1:26
  • The & at the end is standard shell syntax for "run this process in the background and don't wait for it." (It looks like you should learn more about the shell if things like this are part of what you are doing.) A separate log file for the startup can contain the information potentially to be gained before Weblogic's logging kicks in, e.g., as mentioned, if the path of the script you are calling is wrong, the respective error message would vanish into /dev/null otherwise.
    – JyrgenN
    Commented Jul 22, 2014 at 9:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .