Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Oct 2007 20:14:55 +0300
From:      Mike Makonnen <mtm@FreeBSD.Org>
To:        Jay Banks <jay-b@quest4.org>
Cc:        freebsd-rc@freebsd.org
Subject:   Re: Getting a script to run at boot
Message-ID:  <20071006171455.GA71986@terra.mike.lan>
In-Reply-To: <004d01c80830$5447e770$90bd050c@4BANKS>
References:  <004d01c80830$5447e770$90bd050c@4BANKS>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



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