How to get the PID of a process started by /bin/su -c

Solution 1:

Echo the PID inside the commands executed by "su":

/bin/su - $USER -c "cd $PATH;echo $PASSWORD | \
  $JAVA -Xmx256m -jar $PATH/app.jar -d > /dev/null & echo $! > $PIDFILE"