今天小编给大家分享的是linux系统自带程序/bin/true和/bin/false的使用方法,相信大部分人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,话不多说,一起往下吧。
/bin/true返回的是 0
/bin/false返回的是 1 (也有说是非0值)
/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
}
以上就是linux系统自带程序/bin/true和/bin/false使用方法的详细内容了,看完之后是否有所收获呢?如果想了解更多相关内容,欢迎关注亿速云行业资讯!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。