linux:commands:process

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

次のリビジョン
前のリビジョン
最新のリビジョン両方とも次のリビジョン
linux:commands:process [2019/01/06 20:55] – 作成 ともやんlinux:commands:process [2024/03/31 05:27] – [参考文献] ともやん
行 1: 行 1:
 ====== プロセス関連 ====== ====== プロセス関連 ======
 +
 ===== プロセス表示[ps] ===== ===== プロセス表示[ps] =====
 現在実行されているプロセスのスナップショットを表示する。 現在実行されているプロセスのスナップショットを表示する。
-<code+<WRAP color_term
-$ ps +<WRAP color_command><html><pre> 
-</code+<font color="#FF8700"><b>$</b></font> <font color="#26A269">ps</font> 
-<code+</pre></html></WRAP
-   PID TTY          TIME CMD +<WRAP color_result><html><pre
-  2084 pts/   00:00:12 bash +    PID TTY          TIME CMD 
-  3879 pts/   00:00:00 ps + 851455 pts/   00:00:00 zsh 
-</code> + 854417 pts/   00:00:00 ps 
-aux オプションでユーザー、CPU使用率、メモリー使用率などを表示する。 +</pre></html></WRAP> 
-<code+</WRAP> 
-$ ps aux + 
-</code+<html><code>ps fu</code></html> オプションで、ユーザー、階層表示する。 
-<code>+<WRAP color_term> 
 +<WRAP color_command><html><pre> 
 +<font color="#FF8700"><b>$</b></font> <font color="#26A269">ps</font> fu 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND 
 +tomoyan   851455  0.0  0.4   8888  4560 pts/0    Ss   04:42   0:00 -zsh 
 +tomoyan   854512  0.0  0.4   8244  4608 pts/0    R+   05:05   0:00  \_ ps fu 
 +tomoyan    15144  0.0  0.1  10096  1868 pts/1    Ss    3月17   0:02 -zsh 
 +tomoyan   852684  4.9  3.0 867620 29896 pts/1    Sl+  04:48   0:52  \_ /home/tomoyan/.local/pipx/venvs/jupyter 
 +tomoyan   853162  0.0  0.5   8960  5448 pts/2    Ss+  04:49   0:00      \_ /usr/bin/zsh 
 +tomoyan   853311  0.0  0.0      0     0 pts/1    Z+   04:49   0:00      \_ [node] &lt;defunct&gt; 
 +</pre></html></WRAP> 
 +</WRAP> 
 + 
 +<html><code>ps aux</code></html> オプションでユーザー、CPU使用率、メモリー使用率などを表示する。 
 +<WRAP color_term
 +<WRAP color_command><html><pre><font color="#FF8700"><b>$</b></font> <font color="#26A269">ps</font> aux 
 +</pre></html></WRAP
 +<WRAP color_result_hlong><html><pre>
 USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
 root          1  0.1  0.2 105560 12216 ?        Ss   17:52   0:14 /usr/lib/systemd/systemd --switched-root root          1  0.1  0.2 105560 12216 ?        Ss   17:52   0:14 /usr/lib/systemd/systemd --switched-root
-root          2  0.0  0.0      0     0 ?        S    17:52   0:00 [kthreadd] +root        607  0.0  0.0  32760  1840 ?        S&lt;sl 17:52   0:00 /sbin/auditd
-root          3  0.0  0.0      0     0 ?        I<   17:52   0:00 [rcu_gp] +
-root          4  0.0  0.0      0     0 ?        I<   17:52   0:00 [rcu_par_gp] +
-root          6  0.0  0.0      0     0 ?        I<   17:52   0:00 [kworker/0:0H-kblockd] +
-root          8  0.0  0.0      0     0 ?        I<   17:52   0:00 [mm_percpu_wq] +
-root          9  0.2  0.0      0     0 ?        S    17:52   0:18 [ksoftirqd/0] +
-root         10  0.0  0.0      0     0 ?        I    17:52   0:02 [rcu_sched] +
-root         11  0.0  0.0      0     0 ?        I    17:52   0:00 [rcu_bh] +
-root         12  0.0  0.0      0     0 ?        S    17:52   0:02 [migration/0] +
-root         14  0.0  0.0      0     0 ?        S    17:52   0:00 [cpuhp/0] +
-root         15  0.0  0.0      0     0 ?        S    17:52   0:00 [cpuhp/1] +
-root         16  0.0  0.0      0     0 ?        S    17:52   0:00 [migration/1] +
-root         17  0.0  0.0      0     0 ?        S    17:52   0:03 [ksoftirqd/1] +
-root         19  0.0  0.0      0     0 ?        I<   17:52   0:00 [kworker/1:0H-kblockd] +
-root         20  0.0  0.0      0     0 ?        S    17:52   0:00 [cpuhp/2] +
-root         21  0.0  0.0      0     0 ?        S    17:52   0:00 [migration/2] +
-root         22  0.1  0.0      0     0 ?        S    17:52   0:17 [ksoftirqd/2] +
-root         24  0.0  0.0      0     0 ?        I<   17:52   0:00 [kworker/2:0H-kblockd] +
-root         25  0.0  0.0      0     0 ?        S    17:52   0:00 [cpuhp/3] +
-root         26  0.0  0.0      0     0 ?        S    17:52   0:00 [migration/3] +
-root         27  0.9  0.0      0     0 ?        S    17:52   1:21 [ksoftirqd/3] +
-root         29  0.0  0.0      0     0 ?        I<   17:52   0:00 [kworker/3:0H-kblockd] +
-root         30  0.0  0.0      0     0 ?        S    17:52   0:00 [kdevtmpfs] +
-root         31  0.0  0.0      0     0 ?        I<   17:52   0:00 [netns] +
-root         32  0.0  0.0      0     0 ?        S    17:52   0:00 [rcu_tasks_kthre] +
-root         33  0.0  0.0      0     0 ?        S    17:52   0:00 [kauditd] +
-root         36  0.0  0.0      0     0 ?        S    17:52   0:00 [oom_reaper] +
-root         37  0.0  0.0      0     0 ?        I<   17:52   0:00 [writeback] +
-root         38  0.0  0.0      0     0 ?        S    17:52   0:00 [kcompactd0] +
-root         39  0.0  0.0      0     0 ?        SN   17:52   0:00 [ksmd] +
-root         40  0.0  0.0      0     0 ?        SN   17:52   0:01 [khugepaged] +
-root         41  0.0  0.0      0     0 ?        I<   17:52   0:00 [crypto] +
-root         42  0.0  0.0      0     0 ?        I<   17:52   0:00 [kintegrityd] +
-root         43  0.0  0.0      0     0 ?        I<   17:52   0:00 [kblockd] +
-root         44  0.0  0.0      0     0 ?        I<   17:52   0:00 [ata_sff] +
-root         45  0.0  0.0      0     0 ?        I<   17:52   0:00 [md] +
-root         46  0.0  0.0      0     0 ?        I<   17:52   0:00 [edac-poller] +
-root         47  0.0  0.0      0     0 ?        I<   17:52   0:00 [devfreq_wq] +
-root         48  0.0  0.0      0     0 ?        S    17:52   0:00 [watchdogd] +
-root         52  0.0  0.0      0     0 ?        S    17:52   0:03 [kswapd0] +
-root         53  0.0  0.0      0     0 ?        I<   17:52   0:00 [kworker/u257:0-btrfs-worker-high] +
-root        107  0.0  0.0      0     0 ?        I<   17:52   0:00 [kthrotld] +
-root        108  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/24-pciehp] +
-root        109  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/25-pciehp] +
-root        110  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/26-pciehp] +
-root        111  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/27-pciehp] +
-root        112  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/28-pciehp] +
-root        113  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/29-pciehp] +
-root        114  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/30-pciehp] +
-root        115  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/31-pciehp] +
-root        116  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/32-pciehp] +
-root        117  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/33-pciehp] +
-root        118  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/34-pciehp] +
-root        119  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/35-pciehp] +
-root        120  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/36-pciehp] +
-root        121  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/37-pciehp] +
-root        122  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/38-pciehp] +
-root        123  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/39-pciehp] +
-root        124  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/40-pciehp] +
-root        125  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/41-pciehp] +
-root        126  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/42-pciehp] +
-root        127  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/43-pciehp] +
-root        128  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/44-pciehp] +
-root        129  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/45-pciehp] +
-root        130  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/46-pciehp] +
-root        131  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/47-pciehp] +
-root        132  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/48-pciehp] +
-root        133  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/49-pciehp] +
-root        134  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/50-pciehp] +
-root        135  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/51-pciehp] +
-root        136  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/52-pciehp] +
-root        137  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/53-pciehp] +
-root        138  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/54-pciehp] +
-root        139  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/55-pciehp] +
-root        140  0.0  0.0      0     0 ?        I<   17:52   0:00 [acpi_thermal_pm] +
-root        141  0.0  0.0      0     0 ?        S    17:52   0:00 [scsi_eh_0] +
-root        142  0.0  0.0      0     0 ?        I<   17:52   0:00 [scsi_tmf_0] +
-root        143  0.0  0.0      0     0 ?        S    17:52   0:00 [scsi_eh_1] +
-root        144  0.0  0.0      0     0 ?        I<   17:52   0:00 [scsi_tmf_1] +
-root        146  0.0  0.0      0     0 ?        I<   17:52   0:00 [dm_bufio_cache] +
-root        147  0.0  0.0      0     0 ?        I<   17:52   0:00 [ipv6_addrconf] +
-root        153  0.0  0.0      0     0 ?        I<   17:52   0:00 [kstrp] +
-root        339  0.0  0.0      0     0 ?        I<   17:52   0:00 [mpt_poll_0] +
-root        340  0.0  0.0      0     0 ?        I<   17:52   0:00 [mpt/0] +
-root        345  0.0  0.0      0     0 ?        S    17:52   0:00 [scsi_eh_2] +
-root        346  0.0  0.0      0     0 ?        I<   17:52   0:00 [scsi_tmf_2] +
-root        347  0.0  0.0      0     0 ?        I<   17:52   0:00 [ttm_swap] +
-root        348  0.0  0.0      0     0 ?        S    17:52   0:00 [irq/16-vmwgfx] +
-root        358  0.1  0.0      0     0 ?        I<   17:52   0:11 [kworker/2:1H-kblockd] +
-root        359  0.0  0.0      0     0 ?        I<   17:52   0:06 [kworker/0:1H-kblockd] +
-root        360  0.0  0.0      0     0 ?        I<   17:52   0:04 [kworker/1:1H-kblockd] +
-root        372  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-worker] +
-root        373  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-worker-hi] +
-root        374  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-delalloc] +
-root        375  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-flush_del] +
-root        376  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-cache] +
-root        377  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-submit] +
-root        378  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-fixup] +
-root        379  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-endio] +
-root        380  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-endio-met] +
-root        381  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-endio-met] +
-root        382  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-endio-rai] +
-root        383  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-endio-rep] +
-root        384  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-rmw] +
-root        385  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-endio-wri] +
-root        386  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-freespace] +
-root        387  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-delayed-m] +
-root        388  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-readahead] +
-root        389  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-qgroup-re] +
-root        390  0.0  0.0      0     0 ?        I<   17:52   0:00 [btrfs-extent-re] +
-root        391  0.0  0.0      0     0 ?        S    17:52   0:00 [btrfs-cleaner] +
-root        392  0.1  0.0      0     0 ?        S    17:52   0:13 [btrfs-transacti] +
-root        451  0.0  0.0      0     0 ?        I<   17:52   0:00 [kworker/3:1H-kblockd] +
-root        479  0.1  0.5  71756 32424 ?        Ss   17:52   0:17 /usr/lib/systemd/systemd-journald +
-root        504  0.0  0.2  50724 14176 ?        Ss   17:52   0:01 /usr/lib/systemd/systemd-udevd +
-root        568  0.0  0.0      0     0 ?        I<   17:52   0:00 [kworker/u257:2-hci0] +
-root        579  0.0  0.0      0     0 ?        S    17:52   0:00 [jbd2/sda1-8] +
-root        580  0.0  0.0      0     0 ?        I<   17:52   0:00 [ext4-rsv-conver] +
-root        603  0.0  0.0      0     0 ?        I<   17:52   0:00 [rpciod] +
-root        604  0.0  0.0      0     0 ?        I<   17:52   0:00 [xprtiod] +
-root        607  0.0  0.0  32760  1840 ?        S<sl 17:52   0:00 /sbin/auditd+
 root        634  0.0  0.2 258548 16444 ?        Ssl  17:52   0:05 /usr/sbin/rsyslogd -n root        634  0.0  0.2 258548 16444 ?        Ssl  17:52   0:05 /usr/sbin/rsyslogd -n
 root        636  0.0  0.0  17112  5932 ?        Ss   17:52   0:02 /sbin/rngd -f root        636  0.0  0.0  17112  5932 ?        Ss   17:52   0:02 /sbin/rngd -f
行 172: 行 72:
 root       1281  0.0  0.2 252740 12372 ?        Ss   17:53   0:00 /usr/sbin/virtlogd root       1281  0.0  0.2 252740 12372 ?        Ss   17:53   0:00 /usr/sbin/virtlogd
 qemu       1300  7.1  9.8 3008152 599500 ?      Sl   17:53  10:40 /usr/bin/qemu-system-x86_64 -machine acc qemu       1300  7.1  9.8 3008152 599500 ?      Sl   17:53  10:40 /usr/bin/qemu-system-x86_64 -machine acc
-root       1308  0.1  0.0      0     0 ?        S    17:53   0:11 [vhost-1300] 
-root       1311  0.0  0.0      0     0 ?        S    17:53   0:00 [kvm-pit/1300] 
 qemu       1341 13.4 19.2 3543676 1167724 ?     Sl   17:53  19:58 /usr/bin/qemu-system-x86_64 -machine acc qemu       1341 13.4 19.2 3543676 1167724 ?     Sl   17:53  19:58 /usr/bin/qemu-system-x86_64 -machine acc
-root       1359  0.0  0.0      0     0 ?        S    17:53   0:05 [vhost-1341] 
-root       1362  0.0  0.0      0     0 ?        S    17:53   0:00 [kvm-pit/1341] 
 qemu       1398  8.2  9.9 2998624 605712 ?      Sl   17:53  12:21 /usr/bin/qemu-system-x86_64 -machine acc qemu       1398  8.2  9.9 2998624 605712 ?      Sl   17:53  12:21 /usr/bin/qemu-system-x86_64 -machine acc
-root       1410  0.1  0.0      0     0 ?        S    17:53   0:15 [vhost-1398] 
-root       1413  0.0  0.0      0     0 ?        S    17:53   0:00 [kvm-pit/1398] 
 qemu       1445  4.5  9.7 3032820 593312 ?      Sl   17:53   6:48 /usr/bin/qemu-system-x86_64 -machine acc qemu       1445  4.5  9.7 3032820 593312 ?      Sl   17:53   6:48 /usr/bin/qemu-system-x86_64 -machine acc
-root       1463  0.2  0.0      0     0 ?        S    17:53   0:21 [vhost-1445] 
-root       1466  0.0  0.0      0     0 ?        S    17:53   0:00 [kvm-pit/1445] 
 root       1470  0.0  0.1  15832  9240 ?        S    17:54   0:08 /sbin/dhclient -d -q -sf /usr/libexec/nm root       1470  0.0  0.1  15832  9240 ?        S    17:54   0:08 /sbin/dhclient -d -q -sf /usr/libexec/nm
 root       2053  0.2  0.1  39168  9812 ?        Ss   18:16   0:16 sshd: tomoyan [priv] root       2053  0.2  0.1  39168  9812 ?        Ss   18:16   0:16 sshd: tomoyan [priv]
行 189: 行 81:
 tomoyan    2083  0.0  0.0  39168  5404 ?        R    18:17   0:04 sshd: tomoyan@pts/4 tomoyan    2083  0.0  0.0  39168  5404 ?        R    18:17   0:04 sshd: tomoyan@pts/4
 tomoyan    2084  0.1  0.0 225876  4892 pts/4    Ss   18:17   0:12 -bash tomoyan    2084  0.1  0.0 225876  4892 pts/4    Ss   18:17   0:12 -bash
-root       2573  0.5  0.0      0     0 ?        I    18:43   0:29 [kworker/2:1-mm_percpu_wq] +〜省略〜
-root       2680  0.0  0.0      0     0 ?        I    18:53   0:00 [kworker/1:0-mm_percpu_wq] +
-root       2681  0.0  0.0      0     0 ?        I    18:53   0:00 [kworker/0:0-mm_percpu_wq] +
-root       2883  0.1  0.0      0     0 ?        I    19:00   0:05 [kworker/3:1-events_power_efficient] +
-root       3355  0.0  0.0      0     0 ?        I    19:18   0:00 [kworker/u256:1-btrfs-endio-write] +
-root       3814  0.0  0.0      0     0 ?        I    19:47   0:00 [kworker/u256:7-btrfs-endio-meta] +
-root       3856  0.0  0.0      0     0 ?        I    19:52   0:00 [kworker/0:1-cgroup_destroy] +
-root       3887  0.0  0.0      0     0 ?        I    19:54   0:00 [kworker/u256:5-events_unbound] +
-root       4004  0.0  0.0      0     0 ?        I    20:04   0:00 [kworker/u256:0-btrfs-endio-write] +
-root       4006  0.0  0.0      0     0 ?        I    20:04   0:00 [kworker/u256:4-events_unbound] +
-root       4055  0.0  0.0      0     0 ?        I    20:09   0:00 [kworker/2:2-cgroup_destroy] +
-root       4059  0.0  0.0      0     0 ?        I    20:10   0:00 [kworker/u256:2-btrfs-endio-write] +
-root       4096  0.0  0.0      0     0 ?        I    20:12   0:00 [kworker/1:2-cgroup_destroy] +
-root       4187  0.0  0.0      0     0 ?        I    20:17   0:00 [kworker/3:0-ata_sff] +
-root       4207  0.0  0.0      0     0 ?        I    20:19   0:00 [kworker/u256:3-btrfs-endio-write] +
-root       4225  0.0  0.0      0     0 ?        I    20:22   0:00 [kworker/u256:6] +
-root       4227  0.0  0.0      0     0 ?        I    20:22   0:00 [kworker/3:2-ata_sff]+
 tomoyan    4234  0.0  0.0 228192  3972 pts/4    R+   20:22   0:00 ps aux tomoyan    4234  0.0  0.0 228192  3972 pts/4    R+   20:22   0:00 ps aux
 +</pre></html></WRAP>
 +</WRAP>
 +
 +===== プロセス優先度の変更[renice] =====
 +<code>
 +$ sudo renice -3 1982
 +1982 (process ID) 従来の優先順位は 0 で, 新しい優先順位は -3 です
 </code> </code>
  
行 243: 行 126:
     19 root       0 -20                                             kworker/1:0H-kblockd     19 root       0 -20                                             kworker/1:0H-kblockd
     20 root      20                                                 cpuhp/2     20 root      20                                                 cpuhp/2
-    21 root      rt                                         0:00.37 migration/2 
-    22 root      20                                         0:17.64 ksoftirqd/2 
-    24 root       0 -20                                             kworker/2:0H-kblockd 
-    25 root      20                                                 cpuhp/3 
-    26 root      rt                                         0:00.38 migration/3 
-    27 root      20                                         1:21.34 ksoftirqd/3 
-    29 root       0 -20                                             kworker/3:0H-kblockd 
-    30 root      20                                         0:00.02 kdevtmpfs 
-    31 root       0 -20                                             netns 
-    32 root      20                                                 rcu_tasks_kthre 
-    33 root      20                                         0:00.01 kauditd 
-    36 root      20                                                 oom_reaper 
-    37 root       0 -20                                             writeback 
 </code> </code>
 +top コマンドでよく使うキーの説明
 +^ キー ^ 説明 ^
 +| 1 | CPU使用率の表示切替 |
 +| h | ヘルプの表示(ESCキーで戻る) |
 +| c | コマンド名/コマンドライン切替 |
 +| z | カラー/モノクロ切替 |
 +| Shift + w | 設定の保存 |
 +| q | top コマンドの終了 |
 +
 +===== 参考文献 =====
 +[[https://unix.stackexchange.com/questions/372388/how-can-i-make-ps-command-show-memory-in-mb-instead-of-kb|size - How can I make 'ps' command show memory in MB instead of KB? - Unix & Linux Stack Exchange]]\\
 +[[https://atmarkit.itmedia.co.jp/ait/articles/1603/28/news022.html|【 ps 】コマンド――実行中のプロセスを一覧表示する:Linux基本コマンドTips(6) - @IT]]\\
 +
  • linux/commands/process.txt
  • 最終更新: 2024/03/31 05:49
  • by ともやん