2016-10-24 8 views
1

여러 디렉토리에서 Jboss 인스턴스를 바운스하기위한 여러 bash 스크립트가 있습니다. 이 스크립트는 인수를 허용합니다.단일 bash 스크립트를 사용하여 diff 디렉토리에서 여러 bash 스크립트를 실행하려면

시작 | 멈추다 | 다시로드 | 상태 | 재시작.

/opt/xyz/x/X_FE.sh 
/opt/xyz/x/X_BE.sh 
/opt/xyz/y/Y_FE.sh 
/opt/xyz/y/Y_BE.sh 
/opt/xyz/z/Z_BE.sh 

동일한 인수를 허용하고 위에서 언급 한 5 개의 스크립트를 모두 실행하는 단일 bash 스크립트를 갖고 싶습니다.

/opt/singlescript.sh start ---- must execute all the 5 scripts with start argument. 

모든 도움을 주시면 감사하겠습니다.

답변

0

다음과 같이 보일 것입니다. 이이 작업을 수행하는 여러 가지 방법이 있습니다 이것은 GNU 그것과 같은 병렬 사용하여 하나의 방법

#!/bin/bash 
echo "invoking x/X_FE with $1" 
sh /opt/xyz/x/X_FE.sh $1 

echo "invoking x/X_BE with $1" 
sh /opt/xyz/x/X_BE.sh $1 

echo "invoking y/Y_FE with $1" 
sh /opt/xyz/y/Y_FE.sh $1 

echo "invoking x/Y_BE with $1" 
sh /opt/xyz/y/Y_BE.sh $1 

echo "invoking z/Z_FE with $1" 
sh /opt/xyz/z/Z_BE.sh $1 
+0

고마워요. 그것은 효과가 있었다. – Jithin

0

입니다 :

parallel -j1 ::: /opt/xyz/x/X_FE.sh /opt/xyz/x/X_BE.sh /opt/xyz/y/Y_FE.sh /opt/xyz/y/Y_BE.sh /opt/xyz/z/Z_BE.sh ::: start 
: 그들은 병렬 추가 -j1에서 실행할 수없는 경우

parallel ::: /opt/xyz/x/X_FE.sh /opt/xyz/x/X_BE.sh /opt/xyz/y/Y_FE.sh /opt/xyz/y/Y_BE.sh /opt/xyz/z/Z_BE.sh ::: start 
parallel ::: /opt/xyz/x/X_FE.sh /opt/xyz/x/X_BE.sh /opt/xyz/y/Y_FE.sh /opt/xyz/y/Y_BE.sh /opt/xyz/z/Z_BE.sh ::: stop 

관련 문제