I'm going nuts with this one.
I'm writing an init script for a custom java app. Currently I do the following which gives me the proper pid number.
Code:
${STARTCMD} 2>&1 >> /dev/null &
PID=$!
That works perfectly, except that I need to run it as a non-root user. I've tried several ways, but can't find a way to get a pid (or the right pid).
Code:
su - $USER -c ${STARTCMD} 2>&1 >> /dev/null & ## returns the pid for the "su" proc.
I should mention that this is for a RHEL5(Centos5) system, so ideally I would like to use the already provided daemon function from /etc/init.d/functions. If I do it this way I need to specify a user and a pid file. That would be fine, but I can't seem to get the syntax right.. At this point I don't care which way I do it, as long as it works and doesn't involve having to write a wrapper script.
Any help would be appreciated. Thanks!