您的位置:首页 > 运维架构 > Linux

模仿linux系统启动脚本

2016-05-28 17:02 615 查看
实现代码

#!/bin/bash

. /etc/init.d/functions

function usage()

{

echo "$0 {start|stop|restart}"

}

if [ $# -ne 1 ]

then

echo "ttt"

usage

exit 1

fi

case $1 in

start)

action "start..." /bin/true

;;

*)

usage

;;

esac

存为test_1.sh

[root@test# sh test_1.sh

ttt

test_1.sh {start|stop|restart}

[root@test]# sh test_1.sh start

start... [ OK ]

关键代码是. /etc/init.d/functions 和action "start..." /bin/true,失败则是 action "fail..." /bin/false
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: