示例脚本
在/etc/init.d目录下新建脚本hello.sh
#!/bin/bash#### BEGIN INIT INFO# Provides: hello# Required-Start: $remote_fs $syslog# Required-Stop: $remote_fs $syslog# Should-Start: $network $time# Should-Stop: $network $time# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Description: hello world### END INIT INFO#echo "hello world" > /home/wyq/a.log 以update-rc.d命令添加开机启动
wyq@localhost:/etc/init.d$ sudo update-rc.d hello defaults 90update-rc.d: using dependency based boot sequencingupdate-rc.d: error: unable to read /etc/init.d/hello 在debian7系统中,会出现上面错误,需要该用insserv命令
以insserv命令添加开机启动
wyq@localhost:/etc/init.d$ sudo insserv /etc/init.d/hello.shinsserv: warning: script 'hello.sh' missing LSB tags and overrides 如果脚本没有添加metadata信息,会出现上面错误.
insserv用法
insserv myserver #添加服务insserv -r myserver #删除服务insserv -d myserver #使用默认的runlevels |