1

The PID file for this statement is created but it is always empty. When running the shell with -x I see that $! empty, yet at the end the java job is left running in the background as desired. Why is the pid missing?

 su - $USER -c "nohup java $rest_api_opts -jar $app_home/$app_name \ > /dev/null 2>&1& echo $! > $PID" 

1 Answer 1

2

Fixed. The trouble is that $! is expanded too early. So escaping it delayed the expansion

su - $USER -c "nohup java $rest_api_opts -jar $app_home/$app_name \ > /dev/null 2>&1& echo \$! > $PID" 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.