I currently am starting a Java process, and am trying to get its PID using $!
, and writing that to a file. The problem is, when I start the Java process, it goes into its own "console". (I'm not sure what this is called).
I'm not able to write this $!
to a file until I have stopped the process and exited out of its "console", where the PID is then useless.
How would I go about starting the Java process, and getting its PID without ending it?
I am using echo $! > pidfile.pid
to write the PID of the Java process to a file.