Getting a script to run at boot
Mike Makonnen
mtm at FreeBSD.Org
Sat Oct 6 10:13:44 PDT 2007
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.
More information about the freebsd-rc
mailing list