centos开机启动
开机启动方式有三种:
- 把启动程序的命令添加到/etc/rc.d/rc.local文件中,rc.local是在完成所有初始化之后执行的,所以在这里做手脚很合适
- 把写好的启动脚本添加到目录/etc/rc.d/init.d/,然后使用命令chkconfig设置开机启动。
- 把启动程序的命令添加到/etc/rc.d/rc.sysinit 文件中(慎用,防止系统启动不了)
chkconfig命令
chkconfig –list命令:查看开机启动的清单列表
chkconfig xxx on :设置开机启动
[root@localhost ~]# chkconfig MysqLd on
要取消掉某个服务自动启动,只需要将最后的参数 “on” 变更为 “off” 即可
[root@localhost ~]# chkconfig MysqLd off
[root@localhost ~]# chkconfig –-add postfix
查看所有自动启动的服务
[root@localhost init.d]# chkconfig --list
auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
blk-availability 0:off 1:on 2:on 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
csvn 0:off 1:off 2:on 3:on 4:on 5:on 6:off
ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:off
iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off
mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off
multipathd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
MysqLd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
nmb 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ntpdate 0:off 1:off 2:off 3:off 4:off 5:off 6:off
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rdisc 0:off 1:off 2:off 3:off 4:off 5:off 6:off
restorecond 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
smb 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
udev-post 0:off 1:on 2:on 3:on 4:on 5:on 6:off
winbind 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost ~]# chkconfig --list smb
smb 0:off 1:off 2:on 3:on 4:on 5:on 6:off
说明:如果0~6均为off,则说明服务不会在系统启动的时候自动启动。输入:chkconfig smb on 即可启动
修改 /etc/rc.d/rc.local 这个文件
例如将 apache、MysqL、samba、svn 等这些服务的开机自启动问题一起搞定
vim /etc/rc.d/rc.local
#添加以下命令
/usr/sbin/apachectl start
/etc/rc.d/init.d/MysqLd start
/etc/rc.d/init.d/smb start
/usr/local/subversion/bin/svnserve -d
service 服务
当我们输入service命令时,linux会去/etc/rc.d/init.d下去找这个脚本运行
/etc/rc.d/init.d和/etc/init.d 联系区别
[root@webtest ~]# ls -ld /etc/rc.d
drwxr-xr-x. 10 root root 4096 Jun 21 16:48 /etc/rc.d
[root@webtest ~]# ls -ld /etc/init.d
lrwxrwxrwx. 1 root root 11 Jun 21 16:48 /etc/init.d -> rc.d/init.d
原文链接:https://www.f2er.com/centos/380552.html说明:一个是另外一个的软连接