【运维】Linux通过 chkconfig命令将脚本添加成服务

1、脚本格式

#!/bin/bash
#chkconfig: 2345 70 90

# 第二行必须要写上,不然添加失败
# 将该脚本放到/etc/init.d目录下

2、chkconfig的使用

    --add 增加所指定的系统服务

    --del 删除所指定的系统服务

    --list 查看服务情况

    --level <等级代号> 指定读取系统服务要在哪一个执行等级中开启&关闭

   举例: 

   


cat /etc/init.d/hello

-----------------------------------------
#!/bin/bash
#chkconfig: 2345 70 90

echo "hello world"
-----------------------------------------

chkconfig --add hello

-----------------------------------------

service  hello start

输出 hello world 
-----------------------------------------

【运维】Linux通过 chkconfig命令将脚本添加成服务_第1张图片

 

3、参考链接:

Linux chkconfig命令_菜菜啾咪的博客-CSDN博客_chkconfig

你可能感兴趣的:(运维,linux,运维,服务器)