running the script in background

I have a script called startWebLogic.sh which I was running in the background but the problem is which I used the command :- ps -elf | grep "startWebLogic.sh" | grep -v grep to find the process id but I was unable to find the process id for this script and when I checked from the front end the server had been successfully started. Can anyone help me so that I can find the proces is running or not.

You can grep for "[s]tartweblogic.sh" to avoid the grep -v grep.

As for why it couldn't find it -- well, is it running? Did it fail to find it since it wasn't there or just didn't work?

Better form would be for your startweblogic.sh script to create its own PID file somewhere echo $$ > /tmp/weblogic.pid instead of forcing you to grep for it in the process table. (And delete the PID file on exit, preferably in a trap like trap "rm -f /tmp/$$.pid" EXIT Then you could just

[ -f /tmp/weblogic.pid ] && read PID </tmp/weblogic.pid

[ ! -z "$PID" ] && [ -d /proc/"$PID" ] && echo "weblogic is running"

Way to find out pid of last process run in background

$ sleep 10 &
[1]     19959
$ echo $!
19959

The most likely scenario is that the script startWebLogic.sh finished normally.
If the commands which the script executed just cause background services to start, the script will end normally and leave the background processes running.