On Saturday 09 April 2005 12:01, Anders Norrbring wrote:
I need to start a java process and get a valid pid for it to be able to kill it later.
So, I thought I could use startproc in this way 'startproc -f -p /var/run/myproc.pid /usr/bin/java/ jarfil.jar'
But noway.. I don't get a pid file at all. So, how should I do to get a valid pidfile for the process?
1) Choose a directory for the PID file to which you have write access. 2) Give yourself write access to /var/run. 3) Create (as root) a writable sub-directory of /var/run.
I'd probably go with (3). And I'd also use a more distinctive name than "myproc.pid".
Furthermore, the syntax for invoking a so-called "executable JAR file" is "java -jar jarfile.jar". (Assuming the java launcher's directory is in your PATH. Use the full path name, say "/usr/lib/java/bin/java", if it's not.) If the JAR file does not have the necessary manifest information to be "executable," you'll have to discover the name of the class that implements the static main() method that is the entry point for the application.
Randall, I don't know much about the jar file itself, it's the Azureus BitTorrent client. I guess I can find out somehow by unpacking it, or is that not possible? Anyway, I tried what you suggested about a new directory, but no file was written to it. Startproc displays the pid when it exists, but that's the only trace I can get without running a ps to look it up manually, which isn't good since I want to run it scripted. Startproc isn't a "must", I can start it with screen instead if that will make any difference. I thought I could make use of the bash $$ somehow, but it seems like I can't get it to echo the java process pid, but only the pid "before", the parent script's pid that is... Any other suggestions? Anders.