歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> 模仿linux系統啟動腳本

模仿linux系統啟動腳本

日期:2017/3/3 12:19:29   编辑:Linux技術

實現代碼

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

Copyright © Linux教程網 All Rights Reserved