加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

用shell写一个服务启动脚本,速度get!

发布时间:2020-12-15 23:19:07 所属栏目:安全 来源:网络整理
导读:制作服务启动程序:(case+if) vi /etc/init.d/myprog #!/bin/bash#chkconfig:35 90 10#description:Startup script for myprog Servercase "$1" instart)if [ -f /opt/test ];thenecho "myprog服务已经启动 [失败]"elseecho "正在启动 myprog 服务 [确定]
制作服务启动程序:(case+if)
vi /etc/init.d/myprog

#!/bin/bash#chkconfig:35 90 10#description:Startup script for myprog Servercase "$1" instart)if [ -f /opt/test ];thenecho "myprog服务已经启动 [失败]"elseecho "正在启动 myprog 服务 [确定]"touch /opt/testfi;;stop)if [ -f /opt/test ];thenecho "正在停止 myprog 服务 [确定]"rm -rf /opt/testelseecho "myprog服务已经停止 [失败]"fi;;restart)echo "正在重启 myprog 服务 [确定]";;status)if [ -f /opt/test ];thenecho "myprog服务正在运行"elseecho "myprog服务已经停止"fi;;*)echo "用法:$0 {start |stop |restart}";;esac保存退出chmod +x /etc/init.d/myprog ---增加执行权限chkconfig --add myprog ---添加到系统服务中,增加所指定的系统服务,让chkconfig指令得以管理它。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读