From owner-freebsd-hackers Tue Jul 30 5:55: 4 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 88A4937B400 for ; Tue, 30 Jul 2002 05:54:57 -0700 (PDT) Received: from relay03.esat.net (relay03.esat.net [193.95.141.41]) by mx1.FreeBSD.org (Postfix) with ESMTP id CBC8F43E31 for ; Tue, 30 Jul 2002 05:54:56 -0700 (PDT) (envelope-from phil@ipac.ie) Received: from ipac-gw.cr001.ddm.esat.net (mail.rfc-networks.ie) [193.95.188.30] by relay03.esat.net with esmtp id 17ZWWd-00023i-00; Tue, 30 Jul 2002 13:54:55 +0100 Received: from tear.domain (unknown [10.0.1.254]) by mail.rfc-networks.ie (Postfix) with ESMTP id CA4A754834 for ; Tue, 30 Jul 2002 12:58:59 +0100 (IST) Received: by tear.domain (Postfix, from userid 1000) id EFFA72113F; Tue, 30 Jul 2002 13:55:44 +0000 (GMT) Date: Tue, 30 Jul 2002 13:55:44 +0000 From: Philip Reynolds To: freebsd-hackers@freebsd.org Subject: Re: How to keep java code running after logout Message-ID: <20020730135544.C18016@rfc-networks.ie> Reply-To: philip.reynolds@rfc-networks.ie References: <20020730061600.95733.qmail@web12201.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020730061600.95733.qmail@web12201.mail.yahoo.com>; from talkwithpatel@yahoo.com on Mon, Jul 29, 2002 at 11:16:00PM -0700 X-Operating-System: FreeBSD 4.6-RC X-URL: http://www.rfc-networks.ie Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Vijay Patel 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). > 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