如何成功后开始搜索弹性执行操作 [英] how to perform operation after successfully starting elastic search

查看:145
本文介绍了如何成功后开始搜索弹性执行操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一个shell脚本,开始从shell命令弹性搜索和搜索弹性成功启动后我必须执行某些操作。
在我的情况弹性搜索启动,但之后不会发生什么意外连echo命令的作品。

I have to create a shell script to start elastic search from shell command and after successful start of elastic search I have to perform certain operation. In my case elastic search is starts but after that nothing happens not even echo command works.

下面是code样品:<​​/ P>

Here is the code sample :

elasticsearch-1.7.2/bin/elasticsearch   

res=$( curl -w %{http_code} -s --output /dev/null http://localhost:9200)
if [ $res -eq 200 ]
then 
        echo "Elastic search running successfully"  
        Perform operation
fi

谢谢,

推荐答案

一个shell脚本时刻执行1线,直到当前已完成不动到下一行(命令)。

A shell script executes 1 line at time and doesn't move onto the next line (command) until the current one has completed.

您可以使用&放大器; 字符来在后台运行一个命令,那么剩下的命令可以按顺序执行

You can use the & char to run a command in the background, then the remaining commands can be executed in sequence.

#!/bin/bash
elasticsearch-1.7.2/bin/elasticsearch &

/bin/sleep 30 # change to num secs needed for ES to start correctly

res=$( curl -w %{http_code} -s --output /dev/null http://localhost:9200)
if [ $res -eq 200 ]
then 
        echo "Elastic search running successfully"  
        Perform operation
fi

可能的帮助。

这篇关于如何成功后开始搜索弹性执行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆