BSDオプションを使用してPS経由でPPIDを取得する方法

BSDオプションを使用してPS経由でPPIDを取得する方法

私は「ps aux」のすべての出力ヘッダーを提供しますが、PPIDを含むps文字列を探しています。これまでは、ps -efを使用してのみPPID列を取得できます。いろいろな組み合わせを試してみましたが、私の目標を達成する組み合わせを見つけることができませんでした。これは可能ですか?

ベストアンサー1

今、私たちはあなたがどんな人なのかを知っています。本物思う…

-o必要なフィールドを選択するために使用されます。たとえば、

$ ps -eo pid,ppid,%cpu,%mem,args
  PID  PPID %CPU %MEM COMMAND
    1     0  0.0  0.0 /usr/lib/systemd/systemd --system --deserialize 22
...more procs...
 1522  3205  0.0  0.0 nginx: worker process
 1523  3205  0.0  0.0 nginx: worker process
 1525  3205  0.0  0.0 nginx: worker process
 1527  3205  0.0  0.0 nginx: worker process
 1528  3205  0.0  0.0 nginx: worker process
 1529  3205  0.0  0.0 nginx: worker process
 3205     1  0.0  0.0 nginx: master process /usr/sbin/nginx
...more procs...

利用可能なフィールドの完全なリストはマニュアルページにあります。

おすすめ記事