Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jul 2002 13:55:44 +0000
From:      Philip Reynolds <philip.reynolds@rfc-networks.ie>
To:        freebsd-hackers@freebsd.org
Subject:   Re: How to keep java code running after logout
Message-ID:  <20020730135544.C18016@rfc-networks.ie>
In-Reply-To: <20020730061600.95733.qmail@web12201.mail.yahoo.com>; from talkwithpatel@yahoo.com on Mon, Jul 29, 2002 at 11:16:00PM -0700
References:  <20020730061600.95733.qmail@web12201.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Vijay Patel <talkwithpatel@yahoo.com> 69 lines of wisdom included:
> Hi friends,
> 	I have installed FreeBSD 4.5 on my machine. I am also
> having 2 other machines running on linux.
> 	We have developed a code in java which we need to run
> in background for 24 hrs. In linux we use...
> 	java Code1 &

This is fine, however this sets the process into the background,
however the process still has a parent process. It is natural
behaviour, that if a parent process dies, so do the children. In
innatural situations, this is how ``zombie'' or ``defunct''
processes appear.

In (my favourite shell) zsh, putting the program into the background
with ``&|'' can work.
e.g.

$ java Code1 &|
$ jobs
$

as opposed to

$ java Code1 &
$ jobs
[1]  + running    java Test
$

In the second situation however, you can ``disown'' the process,
which will leave the process in the same state as the first.
See zshbuiltins(1).


<snip>

> bash-2.05a$ ps
>   PID  TT  STAT      TIME COMMAND
>  1087  p0- I      0:00.20
> /usr/local/jdk1.3.1/bin/i386/green_threads/java Code1
>  1105  p0  Ss     0:00.01 -bash (bash)
>  1106  p0  R+     0:00.00 ps

Your main problem is that you're trying to run a ``daemon'' process
with Java on a FreeBSD system. As you can see, your Java program is
attacked to a TTY, which is a bad idea for a ``daemon''.

I have come across a wrapper for this, which is located here:
http://www2.dystance.net:8080/ping/djinn/

I can't testify how good or bad this is, but it's something to
consider at least.

> 	It is showing that code is working right now. But
> after 2-3 hours code automatically gets killed. I am
> having good provision for keeping all error log iff my
> code exists with an error. But here i am sure that it
> is getting killed - so i am not getting any error log.

If your code is getting killed after a few hours, I would have a
look at logging information, and where abouts your code is actually
falling over.

Also have a look at the ``nohup(1)'' command. This basically
means that when the shell sends the JVM a signal to terminate (when
you type ``exit'', this is what happens) it ignores it and keeps
running.

$ nohup Java Code1 &

The above is probably your best bet.

I am not that familiar with Java debugging utilities for UNIX,
especially FreeBSD. However your problem seems to be the method for
spawning your program in the background, which I think you need to
rethink.

-- 
Philip Reynolds                  | Technical Director
philip.reynolds@rfc-networks.ie  | RFC Networks Ltd.
http://www.rfc-networks.ie       | +353 (0)1 8832063

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020730135544.C18016>