如何检查是否打开了自制服务

m0rkklqb  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(2)|浏览(376)

我正在使用 elasticsearch 示例作为nosql数据库。这是与一起安装的 brew 在mac os上。
我就是这样开始的 elasticsearch .

brew services start elasticsearch

我想知道是否有一个brew命令(或其他),我可以知道 elasticsearch 示例是否打开。
最后,我要运行一个bash脚本,它执行以下操作:

If elasticsearch is off:
    Turn on elastiscearch
    Proceed
Else:
    Proceed
klr1opcd

klr1opcd1#

快跑:

brew services

样本输出

Name      Status  User Plist
grafana   started mark /Users/mark/Library/LaunchAgents/homebrew.mxcl.grafana.plist
influxdb  started mark /Users/mark/Library/LaunchAgents/homebrew.mxcl.influxdb.plist
mosquitto stopped      
redis     started mark /Users/mark/Library/LaunchAgents/homebrew.mxcl.redis.plist
unbound   stopped

您还可以运行以下命令来获取自制服务的进程id(pid):

launchctl list | grep homebrew

460 0   homebrew.mxcl.influxdb
484 0   homebrew.mxcl.grafana
469 0   homebrew.mxcl.redis
yxyvkwin

yxyvkwin2#

brew services list 提供服务的状态。比如说 brew services list | grep elastiscearch | awk '{ print $2}' 应返回ElasticSearch服务的状态,无论是已启动还是已停止

相关问题