chkconfig.pl - Verify runlevel information for system services

Download this program

SYNOPSIS

  chkconfig -list [name]        # Default
  chkconfig -check              # Not in RH version
  chkconfig -add name
  chkconfig -del name
  chkconfig [-level levels] name <on|off|reset>
  chkconfig [-level levels] name

DESCRIPTION

This is a near clone of chkconfig as found on Redhat systems. The -add and -del examples are aliases for setting a service 'on' and 'off'. The -reset flag removes all symlinks for the service. The -check flag will report broken or orphaned services.

chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories.

This implementation of chkconfig was inspired by the chkconfig command present in the IRIX operating system. Rather than maintaining configu- ration information outside of the /etc/rc[0-6].d hierarchy, however, this version directly manages the symlinks in /etc/rc[0-6].d. This leaves all of the configuration information regarding what services init starts in a single location.

chkconfig has five distinct functions: adding new services for management, removing services from management, listing the current startup information for services, changing the startup information for services, and checking the startup state of a particular service.

When chkconfig is run without any options, it displays usage information. If only a service name is given, it checks to see if the service is configured to be started in the current runlevel. If it is, chkconfig returns true; otherwise it returns false. The --level option may be used to have chkconfig query an alternative runlevel rather than the current one.

If one of 'on', 'off' is specified after the service name, chkconfig changes the startup information for the specified service. The on and off flags cause the service to be started or stopped, respectively, in the runlevels being changed.

By default, the on and off options affect only runlevels 2, 3, 4, and 5. The --level option may be used to specify which runlevels are affected.

Note that for every service, each runlevel has either a start script or a stop script. When switching runlevels, init will not re-start an already-started service, and will not re-stop a service that is not running.

OPTIONS

-add name
This option adds a new service for management by chkconfig. When a new service is added, chkconfig ensures that the service has either a kill entry in every runlevel. If any runlevel is missing such an entry, chkconfig creates the appro- priate entry as specified by the default values in the init script.

-check
Reports on services without links or links without services. This was not part of the original Redhat version.

-del name
The service is removed from chkconfig management, and any symbolic links in /etc/rc[0-6].d which pertain to it are removed.

-etc dir
Used only for debugging, this option will change the location of /etc.

-help
Generates this output.

-level levels
Specifies the run levels an operation should pertain to. It is given as a string of numbers from 0 to 6. For example, --level 35 specifies runlevels 3 and 5.

-list name
This option lists all of the services which chkconfig knows about, and whether they are stopped or started in each runlevel. If name is specified, information in only display about service name.

-notreally
Use this to disable the actual changes to be made in /etc, but rather just show the links to be made or deleted

-number N
When a link is to be created, this forces the number used in the link. This value will override anything specified in the servicefile. If this option is not provided and the servicefile has no number for this service, a random value between 90 and 99 is chosen.

-servicefile file
When a new link is to be created, the name of the actual symbolic link to be created must be determined. A default set of values is provided in the __DATA__ portion of this program, but you may override this by providing your own file.

-verbose
If specified will increase the amount of informational messages generated.

PARAMETERS

servicename [on|off\reset]
Name of a service. This may be followed by a directive. 'on' will enable the service (create a symlink SnnSERVICENAME). 'off' will disable the service (create a symlink KnnSERVICENAME). 'reset' will remove all symlinks related to this service.

EXIT

If no fatal errors are detected, the program exits with a return code of 0. Any error will set a non-zero return code.

AUTHOR

Written by Terry Gliedt <tpg@umich.edu> in 2005 and is made available under terms of the GNU General Public License.