Linux 怎么把自己写的脚本添加到服务里面,即可以使用service命令来调用

chmod 755 filename; mv filename /etc/init.d/; chkconfig --add filename

 

 

 

#!/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

posted @ 2015-03-02 00:04  Dus  阅读(2071)  评论(0编辑  收藏  举报