用shell写一个服务启动脚本,速度get!
制作服务启动程序:(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指令得以管理它。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |