One possible solution is to create a file containing the PID of the process.
On Linux, the right place to store that would be /var/run/myprogram.pid
Make sure to use the Java remove on exit feature when creating the file
so that you don't have left over files. You should also use the
atomic create and check to prevent multiple startups of your process
(or come up with a design allowing multiple PIDs to be stored).
All you have to do to kill the process is read the pid file and send
a TERM signal. Starting with JDK 1.3 you can even catch the TERM
signal in your server, and clean up before exiting.
Alexander
On Wed, Nov 15, 2000 at 09:11:05AM -0500, Francisco Gongora wrote:
> Hello:
>
> We want our application to start automatically at boot, or stop when the
> system shuts down. We are using a startup script ( /etc/rc.d/init.d ) for
> that. After we start the java application (jar), we cannot find the name of
> the process (process id). The name of the command in the process table is
> "java" regardless how many java applications are running at the same time.
> Trying to get the process id using: ps -ef | grep classname, will return
> nothing.
>
> How can I get the name of a process (java application) to be able to kill
> it?
> Is there any other way to run the application automatically when the machine
> boots up?
>
> We will appreciate any help with that. Thanks.
>
> Francisco
>
>
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]