Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
この「ps -eaf」コマンドの出力から 6547 を選択したいとします。その値を選択し、「kill」コマンドに渡してそのプロセスを強制終了したいと考えています。
root 6547 1 0 Aug07 ? 00:00:00 root 14805 2 0 Aug07 ? 00:00:00 root 17443 30043 0 16:21 pts/0 00:00:00
小さなシェル スクリプトを作成する必要がある場合があります。これには、基本的に以下のオプションが含まれます。
pidList=`ps -eaf | awk ' print $2'` for pid in pidList cmd="kill -9 $pid" `$cmd`
基準(プロセス名、ユーザーなど)に基づいて、その特定のプロセスに対してアクションを実行できます。したがって、ここでの要点は、awkコマンドを使用して正確な列を取得することです。
awk