0

ベンチマークスレッドを実行していますが、実行には数時間かかります。ベンチマークスレッドを開始するためのスクリプトは、Pythonを使用して実行されました。ランダムな「foo」が出力されるので、さらに使用するためにgrepしたいと思います。

そこで、これを行うシェルスクリプトを作成しました。

#!/bin/bash

id = `taskset -c 0 python <path>/run-apps.py <thread> | grep "pid" | awk '{print $2}'`
echo $id

以来、スレッドは非常に長い時間がかかります。実行が終了するまでシェルスクリプトが次の行にジャンプできず、IDを開始するとすぐに出力できない可能性があります。

何か問題がありますか?またはどうすればこれを修正できますか?

4

1 に答える 1

1

この文

echo $id

前のステートメントまで実行できません

id=`taskset -c 0 python <path>/run-apps.py <thread> | grep "pid" | awk '{print $2}'`

完了します。必要ない場合は$id、削除して実行してください

taskset -c 0 python <path>/run-apps.py <thread> | grep "pid" | awk '{print $2}'

生成された出力を表示します(ただし、Martijn が指摘したように、バッファリングを無効にする必要がある場合があります)。必要な場合は$id、コマンドを使用しteeて出力のコピーを保存し、同時に標準エラーに出力できます。

id=$(taskset -c 0 python <path>/run-apps.py <thread> |\
     grep "pid" | awk '{print $2}' | tee /dev/stderr) # Or some other file descriptor that goes to your terminal

3 番目のオプションは、一時ファイルを使用することです。

taskset -c 0 python <path>/run-apps.py <thread> | grep "pid" | awk '{print $2}' > tmpfile &
tail --pid $! -f tmpfile # Watch tmpfile until the backgrounded job completes
do-other-job --reading-from tmpfile
于 2013-02-04T21:19:39.737 に答える