2012-10-30 49 views
1

我有一個要求殺死遠程進程的特定patter,pushd啓動的路徑並執行腳本。 我嘗試到目前爲止與在遠程服務器上殺ssh進程,pushd腳本文件夾並執行腳本不是wor

pid=$(ssh -q [email protected] ps -ef|grep $APP|grep $PORT|awk '{print $2}') 

ssh -q [email protected] kill -9 $pid 
ssh -q [email protected] "find /shared/local/path1/app -name "start_app*" -exec grep -nl "9122" {} \;| xargs -0 -I '{}' bash -c 'pushd $(dirname {});bash {};'" 

當我執行上述命令殺處理工作正常。通過將文件夾推送到路徑來查找腳本文件並執行腳本的最後一步不起作用。

由於某種原因,pushd工作不正常。 在本地服務器上的命令做的工作呸與

find /shared/local/path1/app -name "start_app*" -exec grep -nl "9122" {} \;| xarg -0 -I '{}' bash -c 'pushd $(dirname {});bash {};' 

請協助完成這項任務更有效的解決方案。

回答

0

你必須在這裏引用一個錯誤:

ssh -q [email protected] "find /shared/local/path1/app -name "start_app*" -exec grep -nl "9122" {} \;| xargs -0 -I '{}' bash -c 'pushd $(dirname {});bash {};'" 

在代替試試這個:

ssh -q [email protected] "find /shared/local/path1/app -name 'start_app*' -exec grep -nl '9122' {} \;| xargs -0 -I '{}' bash -c 'pushd \$(dirname {});bash {};'" 
相關問題