Centos开机启动脚本一)在/etc/init.d下创建启动脚本,并将其设置为可执行文件(chmod +x)#!/bin/bash# chkconfig: - 85 15# description: Gold Web Server.# Source function library.. /etc/rc.d/init.d/functionshomedir=/home/jack/goldweb/binprog=goldwebpidfile=/var/run/goldweb.pidstart() { echo -n $"Starting $prog: " cd $homedir ./goldweb &}stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile}}case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} ;; restart) stop start ;; *) echo $"Usage: $prog {start|stop|restart|status}" ;;esac注意:必须有下面两个注释,否则无法用chkconfig添加# chkconfig: - 85 15# description: Gold Web Server.其中chkconfig后跟分别是运行级、启动优先级、关闭优先级
# 缺省的运行级,RHS用到的级别如下:
0:关机
1:单用户模式
2:无网络支持的多用户模式
3:有网络支持的多用户模式
4:保留,未使用
5:有网络支持有X-Window支持的多用户模式
6:重新引导系统,即重启
对各个运行级的详细解释:
0 为停机,机器关闭。
1 为单用户模式,就像Win9x下的安全模式类似。
2 为多用户模式,但是没有NFS支持。
3 为完整的多用户模式,是标准的运行级。
4 一般不用,在一些特殊情况下可以用它来做一些事情。例如在笔记本 电脑的电池用尽时,可以切换到这个模式来做一些设置。
5 就是X11,进到X Window系统了。
6 为重启,运行init 6机器就会重启。二)用chkconfig添加开机启动创建服务chkconfig --add newservice检查是否创建成功chkconfig --list newservicenewservice 0:off 1:off 2:off 3:on 4:on 5:on 6:off开启开机启动chkconfig newservice onchkconfig其他操作chkconfig --del newservice //删除服务chkconfig newservice off //关闭开机启动service newservice status //查询服务状态service newservice stop //停止服务service newservice start //启动服务
http://www.dengb.com/Linuxjc/1047310.htmlwww.dengb.comtruehttp://www.dengb.com/Linuxjc/1047310.htmlTechArticleCentos开机启动脚本 一)在/etc/init.d下创建启动脚本,并将其设置为可执行文件(chmod +x) #!/bin/bash# chkconfig: - 85 15# description: Gold Web Server.#...