Linux Daemons
Starting and Stopping Linux Daemons
Section titled “Starting and Stopping Linux Daemons”See also upstart if you are using Ubuntu.
You can start and stop installed daemons such as ‘ntp’ (network time protocol — this will synchronize
your clock) by running the start and stop scripts in /etc/init.d/
# /etc/init.d/ntp startntpd: time slew -0.014128sStarting network time protocol daemon (NTPD) done
# /etc/init.d/ntp stopShutting down network time protocol daemon (NTPD) doneTo have this turn on automatically when the server is rebooted you need to know about runlevels.
A runlevel is a mode the server is currently in. You can see the different levels in /etc/inittab.
My box has the following:
runlevel 0 is System halt (Do not use this for initdefault!)runlevel 1 is Single user moderunlevel 2 is Local multiuser without remote network (e.g. NFS)runlevel 3 is Full multiuser with networkrunlevel 4 is Not usedrunlevel 5 is Full multiuser with network and xdmrunlevel 6 is System reboot (Do not use this for initdefault!)To see the current runlevel, use the runlevel command.
# runlevelN 5This tells us we are in runlevel 5.
To change the daemons to be stopped or started at different runlevels, use the chkconfig program.
To turn on ntp when runlevel 5 is reached, run:
# chkconfig ntp 5