Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

写了个判断 spring cloud 项目是否启动的脚本,主要方法是:

curl http://ip:port/actuator/health | grep status

如果 echo $? 返回是 0,那应用就启动了,现在问题是 curl 会有一大串命令输出到屏幕上,我不想看到这些命令,于是:

curl http://ip:port/actuator/health >/dev/null 2>&1 | grep status

但是放到黑洞文件后,grep 就获取不到值了。。

我现在是把管道分割成单独命令,curl 输出到文件去:

curl http://ip:port/actuator/health >./curl.log 2>&1
grep status ./curl.log >/dev/null 2>&1

有其他办法嘛?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

或许你需要的是安静模式?

curl -s http://ip:port/actuator/health | grep status 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...