首页 > 系统服务 > 详细

ubuntu下使用 chkconfig 是一种习惯

时间:2017-03-30 18:36:33      阅读:202      评论:0      收藏:0      [点我收藏+]

ubuntu下使用 chkconfig 是一种习惯

习惯了chkconfig命令, 闲来写了个脚本模拟下, 步骤很简单。 如下:

第一步, 安装sysv-rc-conf

sudo apt install sysv-rc-conf

第二步, 将如下脚本放于/usr/sbin目录下

 

gord@gord:/usr/sbin$ cat chkconfig 
#!/usr/bin/perl

use strict;
#use warnings;

my $param1 = $ARGV[0];
my $param2 = $ARGV[1];

if ( defined $param2 ){
    if ( $param1 =~ /list/ ){
        system("sysv-rc-conf --list $param2");
    }elsif( $param2 eq on ){
        system("sysv-rc-conf --level 2345 $param1 on");
        system("sysv-rc-conf --list $param1");
    }elsif( $param2 eq off ){
        system("sysv-rc-conf --level 2345 $param1 off");
        system("sysv-rc-conf --list $param1");
        }else{
            print("Usage: chkconfig < option > | --list | [ service_name [ command  < on | off > ] ]\n");
            exit(1);
    }
}else{
    system("sysv-rc-conf --list $param2");

第三步, 赋予权限

chmod 755 chkconfig

使用下,看看效果

gord@gord:/usr/sbin$ chkconfig --list postfix
postfix      0:off    1:off    2:on    3:on    4:on    5:on    6:off

 

ubuntu下使用 chkconfig 是一种习惯

原文:http://www.cnblogs.com/gordonchang/p/6647591.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!