How to: Manage services under Red Hat

From xoa

Jump to: navigation, search

Redhat and CentOS have a tool called chkconfig that shows the status of the various startup scripts in /etc/init.d. You should use chkconfig to manage what gets run when, instead of manually setting symlinks into the various /etc/rc*.d directories.

[edit] Use cclist to see what services start when

chkconfig --list prints a darn-near-unreadable list of services and their run status at each runlevel. The following Perl program, which I called cclist, filters it into something more readable.

#!/usr/bin/perl

open( my $fh, '/sbin/chkconfig --list |' ) or die "Can't open chkconfig: $!"; 

while (<$fh>) {
    if ( /^(\S+)(\s+\d:o(n|ff)){7}/ ) {
        chomp;
        my @cols = split;
        my $service = shift @cols;
        for ( @cols ) {
            my ( $level, $status ) = split /:/;
            print $status eq "on" ? $level : " ";
        }
        print "\t$service\n";
    }
    else {
        print;
    }
}
Personal tools