[root@localhost~]#chkconfig--list显示开机能够自动启动的服务
[root@localhost~]#chkconfig--add***添加开机自动启动***服务
[root@localhost~]#chkconfig--del***删除开机自动启动***服务
[root@localhost~]#setup能够在shell图形终端里面配置的命令,去service里选择
[root@localhost~]#ntsysv在shell终端图形配置开机启动服务命令,选项没上面那个多
setup、rc.local和chkconfig三种方式均可以设置
第一种)
输入#setup指令进入系统服务菜单,选择你想启动的服务好比httpd,而后重起机器或者/etc/rc.d./init.d/httpd
start
第二种)
把启动命令放到/etc/rc.d/rc.local文件里这样就能够每次启动的时候自动启动服务了,例如对于apache,编译好apache后会在安装目录的bin下生成apachectl文件,这是个启动脚本,咱们只须要把这个命令加到rc.local里就能够了
(suse没有rc.local。SUSE是能够这么定义本身的脚本的,若是但愿在切换运行级以前和以后运行本身的脚本,那么能够分别建立:
/etc/init.d/before.local
/etc/init.d/after.local)
echo/usr/local/apache/bin/apachectl>>/etc/rc.d/rc.local,
设置服务自动启动的方式是在rc.local里还能够加入相似如下的一些脚本:
#sshd
/usr/local/sbin/sshd
#proftpd
/usr/local/sbin/proftpd
#apache
/home/apache/bin/apachectlstart
#mysql
/home/mysql/bin/safe_mysqld--port=3306&
#startoracle8ilistenerfirst
su-oracle-c'lsnrctlstart'
#startoracle8i
su-oracle-c'dbstart'
第三种)
经过chkconfig指令.
使用chkconfig命令来把某项服务加到系统的各项运行级别中,步骤以下,
1建立启动脚本.
对于apache,mysql,ssh这样的软件都是本身带的,咱们只要稍微修改一下使之支持chkconfig就能够了
2修改脚本
咱们须要在脚本的前面加上一下2行,才能支持chkconfig命令
#chkconfig:23450892
#
#description:Automatesapacketfilteringfirewallwithipchains.
#
chkconfig:后面定义的使启动服务的运行级别(例子中使2345启动改服务),以及关闭和启动服务的顺序,(上例中关闭服务的顺序使8,启动的顺序使92)
descriptions:对改服务的描述(上例中是ipchains包过滤),你能够换成本身想要的
修改好以后执行
cp你的脚本/etc/rc.d/init.d/脚本名
chmod700/etc/rc.d/init.d/脚本名
chkconfig--add脚本名
例如:
将其加入Linux启动过程,仅在level3,level5级别下运行
[root@Testerinit.d]/sbin/chkconfig--addapache-httpd
[root@Testerinit.d]/sbin/chkconfig--level35apache-httpdon
以后就能够了,之后每次从新启动服务器都会自动启动和关闭咱们的服务了