在/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
wyq@localhost:/etc/init.d$ sudo update-rc.d hello defaults 90
update-rc.d: using dependency based boot sequencing
update-rc.d: error: unable to read /etc/init.d/hello
在debian7系统中,会出现上面错误,需要该用insserv命令
wyq@localhost:/etc/init.d$ sudo insserv /etc/init.d/hello.sh
insserv: warning: script 'hello.sh' missing LSB tags and overrides
如果脚本没有添加metadata信息,会出现上面错误.
insserv myserver #添加服务
insserv -r myserver #删除服务
insserv -d myserver #使用默认的runlevels