Getting a script to run at boot
Mike Makonnen
mtm at FreeBSD.Org
Sat Oct 6 14:10:42 PDT 2007
On Sat, Oct 06, 2007 at 02:30:10PM -0500, Jay Banks wrote:
>
>
> >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?
>
> No I don't. The script specifically has a command line to run as a dameon:
>
> -d, --daemon - daemon mode: make sntop capable of running in the back-
> ground. note, it wont automatically fork into the background.
>
> If I remove -d from the flags in /etc/rc.conf, the script will just display
> to the terminal screen. When I put -d back in, it will run and output
> the html file, refreshes when it is supposed to, and everything looks
> good, but I do not get the prompt back afterwards.
>
> When I reboot, the html output file is wiped out and contains no
> data, and the process does not show up in the running processes.
>
> What exactly does, "it wont automatically fork into the background,"
> mean?
Well, that's the problem then. The '--daemon' switch is misleading. You
should get it to work as expected by adding a '&' at the end of the
command-line. Just for kicks I installed it on my system and with
the attached script and the following in my /etc/rc.conf it seems to
work as expected (though I haven't tried running it on startup):
sntop_enable=yes
sntop_flags="-d -r 30 -f /usr/local/etc/sntoprc -w -e /home/mtm/public_html/sntop.html"
sntop_nice=5
Cheers.
--
Mike Makonnen | GPG-KEY: http://people.freebsd.org/~mtm/mtm.asc
mmakonnen @ gmail.com | AC7B 5672 2D11 F4D0 EBF8 5279 5359 2B82 7CD4 1F55
mtm @ FreeBSD.Org | FreeBSD - http://www.freebsd.org
-------------- next part --------------
#!/bin/sh
#
# PROVIDE: sntop
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
# SET THEM IN THE /etc/rc.conf FILE
#
sntop_enable=${sntop_enable-"NO"}
sntop_flags=${sntop_flags-""}
. /etc/rc.subr
name="sntop"
rcvar=`set_rcvar`
command="/usr/local/bin/${name}"
command_args="&"
load_rc_config $name
run_rc_command "$1"
More information about the freebsd-rc
mailing list