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