Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2039341
  • 博文数量: 519
  • 博客积分: 10070
  • 博客等级: 上将
  • 技术积分: 3985
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-29 14:05
个人简介

只问耕耘

文章分类

全部博文(519)

文章存档

2016年(1)

2013年(5)

2011年(46)

2010年(220)

2009年(51)

2008年(39)

2007年(141)

2006年(16)

我的朋友

分类:

2010-07-22 13:22:36

本语句实现首先检查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.
 
阅读(7679) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~