LoginSignup
3
0

More than 1 year has passed since last update.

Linuxコマンド psのみかた

Posted at

ps -Fで出力される情報まとめ

linux初心者どころか、パソコン詳しくない私が頑張って調べた内容ですので、悪しからず。

psコマンドとは?

OSで実行されているプロセスの一覧を表示するlinuxコマンド
プロセスとは、Linuxにおける実行中のプログラムやアプリケーションの最小単位のこと

最小単位と言われてもという感じではある。。。

-Fオプション

プロセスを完全なフォーマットで表示するとのこと。
勉強にはちょうどいいかなということで、出力する内容を詳しく見ていきます。

出力内容

UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
kamiyama    10     9  0  2514  5116  10 12:24 pts/0    00:00:00 -bash
kamiyama    67    10  0  2654  3296   4 12:47 pts/0    00:00:00 ps -F
  • UID > プロセスを所有しているユーザー
  • PID > プロセスの識別番号
  • PPID > 親プロセスの識別番号
  • C > プロセスのCPU利用状況
  • SZ > プロセスが確保しているメモリサイズ[kB]
  • RSS > 実メモリの使用サイズ
  • PSR > プロセスが現在割り当てられているプロセッサ
  • STIME > プロセス開始時刻
  • TTY > 端末名
  • TIME > 総実行時間
  • CMD > コマンド

ちなみによく使うのは-auxだとか、、、

出力はこちら

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   1756  1084 ?        Sl   12:24   0:00 /init
root         8  0.0  0.0   2124   348 ?        Ss   12:24   0:00 /init
root         9  0.0  0.0   2124   364 ?        R    12:24   0:00 /init
kamiyama    10  0.0  0.0  10056  5116 pts/0    Ss   12:24   0:00 -bash
kamiyama    68  0.0  0.0  10616  3288 pts/0    R+   12:59   0:00 ps aux
  • USER > プロセスを所有しているユーザー(UID)
  • PID > プロセスの識別番号
  • %CPU > CPU使用率
  • %MEM > 実メモリ使用率
  • VSZ > 仮想サイズを含めた使用サイズ[kB]
  • RSS > 実メモリの使用サイズ
  • TTY > 端末名
  • STAT > プロセスの状態
  • START > プロセス開始時刻(STIME)
  • TIME > 総実行時間
  • COMMAND > コマンド(CMD)

STATの内容について

STATの内容について検索してみましたが、記事によって書いている内容が微妙にちがってややこしかったです。
とりあえず、自分の環境で man ps して出てきた結果はこんな感じでした。

PROCESS STATE CODES
       Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display
       to describe the state of a process:

               D    uninterruptible sleep (usually IO)
               I    Idle kernel thread
               R    running or runnable (on run queue)
               S    interruptible sleep (waiting for an event to complete)
               T    stopped by job control signal
               t    stopped by debugger during the tracing
               W    paging (not valid since the 2.6.xx kernel)
               X    dead (should never be seen)
               Z    defunct ("zombie") process, terminated but not reaped by its parent

       For BSD formats and when the stat keyword is used, additional characters may be displayed:

               <    high-priority (not nice to other users)
               N    low-priority (nice to other users)
               L    has pages locked into memory (for real-time and custom IO)
               s    is a session leader
               l    is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
               +    is in the foreground process group
               

ほかの記事をみて重要そうなのは以下のSTAT

  • R > 稼働中
  • S > 割り込み可能なスリープ中
  • D > 割り込み不可なスリープ中
  • T > 終了処理中
  • Z > すでに実体がないゾンビプロセス
  • W > 実メモリ上にはなく、スワップアウトしている
  • N > 優先度低い(プロセスの優先度を示す値。範囲は-20〜19で、値が大きいほど優先度が低いらしい。)
  • < > 優先度高い
  • s > セッションリーダ
  • l > プロセス生成中
  • + > フォアグラウンドのプロセスグループ

まとめ

同じ内容でもカラム名が違うのがややこしい。
もっとも、慣れてくると確認するところが決まってくるのかもしれませんが。

参考

一番詳しそうだったページ。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0