PID / Startscript

Hi,

I have a startscript on solaris 10 which does not work properly.

#!/sbin/sh
PIDFILE=/opt/app_y/PID.log

case $1 in

'start')
        /usr/local/bin/app_y -C /opt/app_y/local.cfg
        echo $! > $PIDFILE
        ;;

esac
exit $?

The problem is that the PIDFILE is empty. What's wrong? How can I geht the PID from the process I started?

Thanks.

rgds,
vic

$! is set to the PID of the last process run in the background (means, with an & at the end or started with bg)
Off the top op my head I know no program or shell builtin to return the PID of the last program run, that's usually done in the program itself.

Is it possible to do a ps -ef and to grep the process, followed by using the awk to filter the PID?

That means I should start the process with ...

... instead of ...

Sure - I could awk for the PID but I thought there is a "better" way.

rgds,
vic