How to get the PID of a process started by /bin/su -c
Posted
by
crash3k
on Server Fault
See other posts from Server Fault
or by crash3k
Published on 2012-04-02T21:49:50Z
Indexed on
2012/04/02
23:32 UTC
Read the original article
Hit count: 205
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.
© Server Fault or respective owner