本语句实现首先检查JBoss进程,如果不存在则启动JBoss。
ps -ef |grep $USER > temp.txt && grep "java -server -Xms2G -Xmx2G" temp.txt && echo jboss is started || ($JBOSS_HOME/bin/run.sh && sleep 120)
解释:
1, 如果写成 ps -ef |grep $USER | grep "java -server -Xms2G -Xmx2G" && echo jboss is started || ($JBOSS_HOME/bin/run.sh && sleep 120) 将无法实现所需功能。
ps -ef |grep $USER | grep "java -server -Xms2G -Xmx2G" 永远返回 0,成功
ps -ef |grep $USER | grep "abcdefg" 同样永远返回 0,成功
2,($JBOSS_HOME/bin/run.sh && sleep 120),这两个小括号不可省略。
3,&&
AND logical operator. In a test construct, the && operator causes a return of 0 (success) only if both the linked test conditions are true.
4,||
OR logical operator. In a test construct, the || operator causes a return of 0 (success) if either of the linked test conditions is true.
阅读(7758) | 评论(0) | 转发(0) |