11.2.Â Starting Services

Contributed by TomRhodes.

Many users install third party software on FreeBSD from the
Ports Collection and require the installed services to be
started upon system initialization. Services, such as
mail/postfix or
www/apache22 are just two of the many
software packages which may be started during system
initialization. This section explains the procedures available
for starting third party software.

In FreeBSD, most included services, such as cron(8), are
started through the system startup scripts.

11.2.1.Â Extended Application Configuration

Now that FreeBSD includes rc.d,
configuration of application startup is easier and provides
more features. Using the key words discussed in
SectionÂ 11.4, “Managing Services in FreeBSD”, applications can be set to
start after certain other services and extra flags can be
passed through /etc/rc.conf in place of
hard coded flags in the startup script. A basic script may
look similar to the following:

This script will ensure that the provided
utility will be started after the
DAEMON pseudo-service. It also provides a
method for setting and tracking the process ID
(PID).

This application could then have the following line placed
in /etc/rc.conf:

utility_enable="YES"

This method allows for easier manipulation of command
line arguments, inclusion of the default functions provided
in /etc/rc.subr, compatibility with
rcorder(8), and provides for easier configuration via
rc.conf.

11.2.2.Â Using Services to Start Services

In some cases, it may make more sense to use
cron(8) to start system services. This approach
has a number of advantages as cron(8) runs these
processes as the owner of the crontab(5). This allows
regular users to start and maintain their own
applications.

The @reboot feature of cron(8),
may be used in place of the time specification. This causes
the job to run when cron(8) is started, normally during
system initialization.