How to get the PID of a process started by /bin/su -c
- by crash3k
I'm writing a init.d-script for an java-app. But the java-app should be run by another user.
(The OS I'm using is Debian Squeeze.)
I already got this:
/bin/su - $USER - c "cd $PATH;echo $PASSWORD | $JAVA -Xmx256m -jar $PATH/app.jar -d > /dev/null" & PID=$!
/bin/su - $USER - c "echo $PID > $PIDFILE"
But this will of course only save the pid of the "/bin/su"-process instead of the pid of the created java-process.