1. 编辑启动文件
启动文件路径:etc/rc.local
vim /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/etc/init.d/zabbix_server start #zabbix开机启动
zabbix_server是脚本可以通过/etc/init.d/zabbix_server start直接执行
也可以使用service zabbix_server start
2. 通过脚本执行
将写好的脚本放到目录/etc/rc.d/init.d/下,系统启动后就会自动执行该目录下的所有shell脚本
3. 注册系统服务
比如我想把某个已经安装了的服务添加为系统服务,可以执行以下命令:
chkconfig --add 服务名称 (首先,添加为系统服务,注意add前面有两个横杠)
chkconfig -leve 启动级别 服务名 on
(说明,3级别代表在命令行模式启动,5级别代表在图形界面启动,on表示开启)
chkconfig -leve 启动级别 服务名 off
(说明,off表示关闭自启动)
chmod +x mysqld #增加执行权限
chkconfig --add mysqld #把hahad添加到系统服务列表
chkconfig mysqld on #设定hahad的开关(on/off)
chkconfig --list mysqld #就可以看到已经注册了hahad的服务
例如mysqld这种打不开的系统文件
可以添加到系统服务进行