shell-script - shell 如何获取 nginx 配置文件位置?
本文介绍了shell-script - shell 如何获取 nginx 配置文件位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
我的脚本想自动获取 nginx.conf 位置。
如:运行脚本返回:
/usr/local/nginx/conf/nginx.conf
解决方案
通过nginx -t
获得
nginx=`nginx -t 2>&1 | grep configuration`
if [ ! -z "$nginx" ];then
nginxtmp="${nginx#*file}"
nginxf="${nginxtmp%test*}"
echo $nginxf
fi
这篇关于shell-script - shell 如何获取 nginx 配置文件位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文