0

このシェル スクリプトから ID でプロセスを強制終了しようとしています。

# based on
# http://stackoverflow.com/questions/6437602/shell-script-to-get-the-process-id-on-linux
output=`ps -ax|grep Ad[o]be\ After\ Effects\ CS6`;
# set -- parses the ps output into words,
# and $1 is the first word on the line
# which happens to be the process ID
set -- $output;
pid=$1;
echo "I'm about to kill process " $pid;
killall -SEGV $pid;

しかし、それは私にその結果を与えます

No matching processes belonging to you were found  

同じ ID を使用してスクリプトがエコーし、コマンドを直接実行すると、本来の処理が行われます。

kill -SEGV 50283  

違いは何ですか?そして、スクリプトが「自分」のように動作するようにするにはどうすればよいですか (ユーザー権限のあるものだと思います)。

4

1 に答える 1

1

killallスクリプトでは、名前でプロセスを検索すると言います。あなたの端末killでは、PIDを取ると言います。前者は誤りですが、似たようなものを自分で実装するのではなく、スクリプトで killall を使用する必要があることはほぼ間違いありません。

于 2013-02-17T09:09:06.290 に答える