rc.d scripts

Kevin Brunelle kruptos at mlinux.org
Mon Mar 26 03:46:37 UTC 2007

> >Does anyone know how to make a script in /etc/rc.d run last?  For instance
> >I want dhclient to be the last script in /etc/rc.d/ to run.  Any help is
> >much appreciated.
> This may have already been answered by others, but I believe just rename
> the script with a prefix of "z" for example: "zmyscript.sh" or "zzmyscript"
> to make it very last beyond the first one with a "z".
> It works for me.

I have my suspicions regarding this working as you describe.  As the order 
isn't related to the filename but to the REQUIRE tags inside the file.  It is 
actually a non-trivial thing to make something run last.  It seems like it 
should be easy but the system doesn't work that way.

For example, adding a requirement for bgfsck (which was also last on my system 
when I did this) moved bgfsck down the list... and still left dhclient 4th 
from last.  In fact, it took the addition of:

# REQUIRE: bgfsck bsnmpd bridge bluetooth

to actually make it the last thing run.  And that is not a sure thing 
either... as soon as the system is updated it is likely to change.

You could edit /etc/rc and add a skip for dhclient (to prevent it from being 
run) and then a couple lines to get just it (with rcorder -k) at the very end 
of /etc/rc to execute it at the very end.  You would need to add a keyword 
declaration in /etc/rc.d/dhclient

It's extremely non-standard but if absolutely required, it would work.  Or 
there probably are other ways.  Still, the exact order of scripts [under the 
current system] is not meant to be fixed and static.  It is meant to be 
flexible so things can be added and removed without worry.


More information about the freebsd-questions mailing list