From owner-freebsd-rc@FreeBSD.ORG Sat Oct 6 17:13:44 2007 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 063DA16A41B for ; Sat, 6 Oct 2007 17:13:44 +0000 (UTC) (envelope-from mtm@FreeBSD.Org) Received: from terra.mike.lan (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 1300B13C45A; Sat, 6 Oct 2007 17:13:41 +0000 (UTC) (envelope-from mtm@FreeBSD.Org) Received: by terra.mike.lan (Postfix, from userid 1000) id 7F449695C1; Sat, 6 Oct 2007 20:14:55 +0300 (EAT) Date: Sat, 6 Oct 2007 20:14:55 +0300 From: Mike Makonnen To: Jay Banks Message-ID: <20071006171455.GA71986@terra.mike.lan> References: <004d01c80830$5447e770$90bd050c@4BANKS> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <004d01c80830$5447e770$90bd050c@4BANKS> User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD/7.0-CURRENT (i386) Cc: freebsd-rc@freebsd.org Subject: Re: Getting a script to run at boot X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Oct 2007 17:13:44 -0000 On Sat, Oct 06, 2007 at 10:47:54AM -0500, Jay Banks wrote: > I'm having a lot of trouble getting scripts to run on startup. It seems like a simple concept, but I reboot and reboot and reboot, and the script isn't running. I've had to fight with stuff before but I can usually get it going (arpwatch, mpd, etc.). Now I'm trying to get sntop to run now and I'm getting nowhere. > A few things would help diagnose this problem: o FreeBSD version o output with rc_debug=yes in /etc/rc.conf o the output of: ls -l /usr/local/etc/rc.d o the contents of the local_startup knob i.e: grep local_startup /etc/defaults/rc.conf /etc/rc.conf Also, I'm not sure how up-to-date the handbook is. You should probably also read rc(8). > Here is my sntop setup. > > I created /usr/local/etc/rc.d/sntop.sh (with chmod 755 as per the docs). Lose the .sh suffix. The only rc.d scripts that should end in .sh are scripts that need to run from within the parent script. I doubt there's a need in this case. > > Here is the script, which I got from the FreeBSD handbook: > > #!/bin/sh > # > # PROVIDE: sntop > # REQUIRE: DAEMON > # KEYWORD: shutdown > #!/bin/sh > # > # PROVIDE: sntop > # REQUIRE: DAEMON > # KEYWORD: shutdown Is the above duplication a 'copy&paste' mistake or is it really in the script? If so, this may be your problem right here. > > start_cmd="echo \"Starting ${name}.\"; /usr/bin/nice -5 ${command} ${sntop_flags > } ${command_args}" You can get rid of this line by simply putting sntop_nice="5" in /etc/rc.conf. > > If I change directory to /usr/local/etc/rc.d and do: > > perl sntop.sh start why perl? > > The sntop will start and show up running in the system processes. It seems to refresh and all of the other flags seem to work. However, if I close the terminal session, that's it, it's dead. > This may mean that the program didn't damonize. If it didn't then obviously it will terminate when you terminate the terminal you started it from. Do you get your prompt back after you run this command? Cheers, Mike.