#!/bin/bash
#chkconfig: 345 85 15
#description:httpd
然后保存,执行。
chkconfig httpd –add 创建系统服务
现在就可以使用service 来 start or restart
1、第一行3个数字参数意义分别为:哪些Linux级别需要启动httpd(3,4,5);启动序号(85);关闭序号(15)。
2、保存后执行:chkconfig --add httpd,成功添加。
3、在rc3.d、rc4.d、rc5.d路径中会出现S85httpd的链接文件,其他运行级别路径中会出现K61httpd的链接文件。
4、运行chkconfig --list httpd
#!/bin/bash
# chkconfig: - 90 10
# description: just a test
echo "Hello,$1"
# mv test /etc/init.d/
# chmod +x /etc/init.d/test
# chkconfig --add test
# service test start
//可以看到Hello,start表示成功
如果有什么不懂的话可以去看看《Linux就该这么学》这本书,非常适合新手学习Linux。