title: Use script to launch a nohup java command and get process id RHEL
body: <p>I am trying to use a script to start a nohup command.  I have written a test program in Java to launch via the script, TestScript.java.  My script contains the following:</p>
  
  <pre><code>#!/bin/bash
  cd /home/user/ejava
  nohup java TestScript &gt; TestScript.out &amp;
  echo $! &gt; /home/user/ejava/TestScript.pid
  </code></pre>
  
  <p>I use echo $! to get the last process ID and store it to a temp file.  When I look in the TestScript.pid, the value is 37458.</p>
  
  <p>When I run a 'ps -elf | grep TestScript', I get:</p>
  
  <pre><code>0 S user    37458     1  0  80   0 -  1065 rt_sig 11:51 pts/0    00:00:00 /bin/ksh /folder/tools/Linux_x86_64/bin/java TestScript
  0 S user    37463 37458  0  80   0 - 8813549 futex_ 11:51 pts/0  00:00:00 /folder/tools/Linux_x86_64/bin/../java/jre_Linux_x86_64/bin/java TestScript
  0 S user    37516 36224  0  80   0 -  1595 -      11:52 pts/0    00:00:00 grep TestScript
  </code></pre>
  
  <p>If I kill job 37458, then 37463 is still running and my output from the nohup is still being updated.  The job is not killed.</p>
  
  <p>How can I get the process id 37463 returned (or whatever correlates to the command with futex in it) so I can store it in a file and later use it to kill the process with another script?  I would prefer not to have to search for the process ID but rather get it returned by some process.</p>