2016-10-24 135 views
1

我有多個bash腳本來在多個目錄中彈出Jboss實例。這些腳本接受參數使用單個bash腳本在diff目錄中執行多個bash腳本

start |停止|重新加載|狀態|重新開始。

/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 

我希望有它接受相同參數的單bash腳本,並執行所有上述5個腳本。

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

任何幫助將不勝感激。

回答

0

它看起來像這樣。有多種方法可以做到這一點,這只是一種方式

#!/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

使用GNU並行它看起來像:

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 

如果他們不能在並行加法-j1運行:

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