/bin/true /bin/false作用

/ binに/真/ビン/偽プログラムシステムであるLinuxの付属
/ binに/真戻り0
/ビン/ 1を偽に戻る(非ゼロ値を前記)

値は、一般的に、独自のロジック?Aに応じて$を設定するには、自己書かれたスクリプトのために使用されています


/bin/true
echo $?
#结果
0

/bin/false
echo $?
#结果
1

説明書

#两个function,这两个函数引用了 /etc/init.d/functions ,使用了action函数
#
[server]-[root@arrow ~]$action "test" /bin/true ;echo $?
test                                                       [  OK  ]
0

[server]-[root@arrow ~]$action "test" /bin/false ;echo $?
test                                                       [  OK  ]
1

#注意下面实际echo $? 返回的 0  是action的结果
#上面的两条返回的是true false的结果
[server]-[root@arrow ~]$action "test"  ;echo $?
test                                                       [  OK  ]
0

------------------------------------------------------------------------------------------------------
Start_Nginx(){
if [ -f $pidfile ];then
        echo "Nginx is running"
else
        /usr/local/nginx/sbin/nginx &>/dev/null
        action "Nginx is Started" /bin/true
fi
}
###########################################################
Stop_Nginx(){
if [ -f $pidfile ];then
        /usr/local/nginx/sbin/nginx -s stop &>/dev/null
        action "Nginx is Stopped" /bin/true
else
        action "Nginx is Stopped" /bin/false
fi
}

おすすめ

転載: blog.51cto.com/14316149/2477633