当前位置:   article > 正文

妙用 ps cmd_bamfdeamon

bamfdeamon

常用的

ps -aux
ps -ef 
ps -eLf :可以显示线程列 LWP 等对于分析如下代码特别有帮助     				
		  t = threading.Thread(target=dispatcher_flow, args=(name, age))
          t.start()
ps -xj 或 ps -ajx:可以显示出进程组 ID 和session ID, 对于理解 Daemon 进程和 setsid 非常有帮助


批量杀进程:
	pgrep -f abc 匹配出含abc的进程 并输出进程的pid
	pkill -f abc 杀掉含abc的所有进程
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

man ps:
SIMPLE PROCESS SELECTION
   a      Lift the BSD-style "only yourself" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like.  The set of processes selected in this manner is in
          addition to the set of processes selected by other means.  An alternate description is that this option causes ps to list all processes with a terminal (tty), or to list all processes when used together with the x option.

   -A     Select all processes.  Identical to -e.

   -a     Select all processes except both session leaders (see getsid(2)) and processes not associated with a terminal.

   -d     Select all processes except session leaders.

   --deselect
          Select all processes except those that fulfill the specified conditions (negates the selection).  Identical to -N.

   -e     Select all processes.  Identical to -A.

   g      Really all, even session leaders.  This flag is obsolete and may be discontinued in a future release.  It is normally implied by the a flag, and is only useful when operating in the sunos4 personality.

   -N     Select all processes except those that fulfill the specified conditions (negates the selection).  Identical to --deselect.

   T      Select all processes associated with this terminal.  Identical to the t option without any argument.

   r      Restrict the selection to only running processes.

   x      Lift the BSD-style "must have a tty" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like.  The set of processes selected in this manner is in
          addition to the set of processes selected by other means.  An alternate description is that this option causes ps to list all processes owned by you (same EUID as ps), or to list all processes when used together with the a option.


OUTPUT FORMAT CONTROL
   These options are used to choose the information displayed by ps.  The output may differ by personality.

   -c     Show different scheduler information for the -l option.

   --context
          Display security context format (for SELinux).

   -f     Do full-format listing. This option can be combined with many other UNIX-style options to add additional columns.  It also causes the command arguments to be printed.  When used with -L, the NLWP (number of threads) and LWP (thread ID) columns will
          be added.  See the c option, the format keyword args, and the format keyword comm.

   -F     Extra full format.  See the -f option, which -F implies.

   --format format
          user-defined format.  Identical to -o and o.

   j      BSD job control format.

   -j     Jobs format.


THREAD DISPLAY
   H               Show threads as if they were processes

   -L              Show threads, possibly with LWP and NLWP columns

   -T              Show threads, possibly with SPID column

   m               Show threads after processes

   -m              Show threads after processes
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59

Demo:
root@robert-Ubuntu:/dev# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 10月08 ?      00:00:07 /sbin/init splash
root         2     0  0 10月08 ?      00:00:00 [kthreadd]
root         4     2  0 10月08 ?      00:00:00 [kworker/0:0H]
root         6     2  0 10月08 ?      00:00:00 [mm_percpu_wq]
root         7     2  0 10月08 ?      00:00:01 [ksoftirqd/0]
root         8     2  0 10月08 ?      00:06:49 [rcu_sched]
root         9     2  0 10月08 ?      00:00:00 [rcu_bh]
root        10     2  0 10月08 ?      00:00:00 [migration/0]
root        11     2  0 10月08 ?      00:00:01 [watchdog/0]
root        12     2  0 10月08 ?      00:00:00 [cpuhp/0]
root        13     2  0 10月08 ?      00:00:00 [cpuhp/1]
root        14     2  0 10月08 ?      00:00:01 [watchdog/1]
root        15     2  0 10月08 ?      00:00:00 [migration/1]
root        16     2  0 10月08 ?      00:00:31 [ksoftirqd/1]
root        18     2  0 10月08 ?      00:00:00 [kworker/1:0H]
root        19     2  0 10月08 ?      00:00:00 [kdevtmpfs]
root        20     2  0 10月08 ?      00:00:00 [netns]
root        21     2  0 10月08 ?      00:00:00 [rcu_tasks_kthre]
root        22     2  0 10月08 ?      00:00:00 [kauditd]
root        24     2  0 10月08 ?      00:00:00 [khungtaskd]
root        25     2  0 10月08 ?      00:00:00 [oom_reaper]
root        26     2  0 10月08 ?      00:00:00 [writeback]
root        27     2  0 10月08 ?      00:00:00 [kcompactd0]
root        28     2  0 10月08 ?      00:00:00 [ksmd]
root        29     2  0 10月08 ?      00:00:00 [khugepaged]
root        30     2  0 10月08 ?      00:00:00 [crypto]
root        31     2  0 10月08 ?      00:00:00 [kintegrityd]
root        32     2  0 10月08 ?      00:00:00 [kblockd]
root        33     2  0 10月08 ?      00:00:00 [ata_sff]
root        34     2  0 10月08 ?      00:00:00 [md]
root        35     2  0 10月08 ?      00:00:00 [edac-poller]
root        36     2  0 10月08 ?      00:00:00 [devfreq_wq]
root        37     2  0 10月08 ?      00:00:00 [watchdogd]
root        40     2  0 10月08 ?      00:00:00 [kswapd0]
root        41     2  0 10月08 ?      00:00:00 [kworker/u5:0]
root        42     2  0 10月08 ?      00:00:00 [ecryptfs-kthrea]
root        85     2  0 10月08 ?      00:00:00 [kthrotld]
root        86     2  0 10月08 ?      00:00:00 [acpi_thermal_pm]
root        87     2  0 10月08 ?      00:00:00 [scsi_eh_0]
root        88     2  0 10月08 ?      00:00:00 [scsi_tmf_0]
root        89     2  0 10月08 ?      00:00:00 [scsi_eh_1]
root        90     2  0 10月08 ?      00:00:00 [scsi_tmf_1]
root        96     2  0 10月08 ?      00:00:00 [ipv6_addrconf]
root       105     2  0 10月08 ?      00:00:00 [kstrp]
root       122     2  0 10月08 ?      00:00:00 [charger_manager]
root       162     2  0 10月08 ?      00:00:00 [scsi_eh_2]
root       163     2  0 10月08 ?      00:00:00 [scsi_tmf_2]
root       166     2  0 10月08 ?      00:00:00 [kworker/0:1H]
root       167     2  0 10月08 ?      00:00:02 [kworker/1:1H]
root       189     2  0 10月08 ?      00:00:00 [jbd2/sda1-8]
root       190     2  0 10月08 ?      00:00:00 [ext4-rsv-conver]
root       231     1  0 10月08 ?      00:00:03 /lib/systemd/systemd-journald
root       247     1  0 10月08 ?      00:00:00 /lib/systemd/systemd-udevd
root       344     2  0 10月08 ?      00:00:00 [iprt-VBoxWQueue]
root       382     2  0 10月08 ?      00:00:00 [ttm_swap]
message+   633     1  0 10月08 ?      00:00:04 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root       661     1  0 10月08 ?      00:00:03 /usr/sbin/NetworkManager --no-daemon
root       662     1  0 10月08 ?      00:00:00 /lib/systemd/systemd-logind
root       666     1  0 10月08 ?      00:00:06 /usr/lib/accountsservice/accounts-daemon
avahi      670     1  0 10月08 ?      00:00:00 avahi-daemon: running [robert-Ubuntu.local]
root       682     1  0 10月08 ?      00:00:00 /usr/sbin/cron -f
syslog     683     1  0 10月08 ?      00:00:00 /usr/sbin/rsyslogd -n
root       706     1  0 10月08 ?      00:00:00 /usr/sbin/acpid
avahi      776   670  0 10月08 ?      00:00:00 avahi-daemon: chroot helper
root       812     1  0 10月08 ?      00:00:10 /usr/sbin/irqbalance --pid=/var/run/irqbalance.pid
root       905     1  0 10月08 ?      00:00:00 /usr/sbin/sshd -D
root       907     1  0 10月08 ?      00:00:00 /usr/sbin/vsftpd /etc/vsftpd.conf
root       921     1  0 10月08 ?      00:00:00 /usr/lib/policykit-1/polkitd --no-debug
root       938     1  0 10月08 ?      00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data   939   938  0 10月08 ?      00:00:00 nginx: worker process
www-data   940   938  0 10月08 ?      00:00:27 nginx: worker process
redis      960     1  0 10月08 ?      00:05:30 /usr/bin/redis-server 127.0.0.1:6379
root       969   661  0 10月08 ?      00:00:16 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /var/run/dhclient-enp0s9.pid -lf /var/lib/NetworkManager/dhclient-b61329b0-4973-32ee-ba8c-f7212a5fd39c-enp0s9.lease -cf /var/lib/NetworkManager/dhclient-e
root       985     1  0 10月08 ?      00:00:00 /usr/sbin/lightdm
root       998   985  0 10月08 tty7   00:00:56 /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
root      1000   661  0 10月08 ?      00:00:11 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /var/run/dhclient-enp0s8.pid -lf /var/lib/NetworkManager/dhclient-5e979922-23f3-3eaf-8f5f-2dd9d703628f-enp0s8.lease -cf /var/lib/NetworkManager/dhclient-e
root      1001   661  0 10月08 ?      00:00:11 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /var/run/dhclient-enp0s3.pid -lf /var/lib/NetworkManager/dhclient-f1d56f04-8693-3fff-9b39-2ee4adc5b39e-enp0s3.lease -cf /var/lib/NetworkManager/dhclient-e
nobody    1062   661  0 10月08 ?      00:00:00 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/var/run/NetworkManager/dnsmasq.pid --listen-address=127.0.1.1 --cache-size=0 --conf-file=/dev/null --proxy-dnssec --enable-dbus=or
whoopsie  1459     1  0 10月08 ?      00:00:00 /usr/bin/whoopsie -f
root      1475     1  0 10月08 tty1   00:00:00 /sbin/agetty --noclear tty1 linux
root      1598   985  0 10月08 ?      00:00:00 lightdm --session-child 12 19
rtkit     1852     1  0 10月08 ?      00:00:03 /usr/lib/rtkit/rtkit-daemon
root      1919     1  0 10月08 ?      00:00:03 /usr/lib/upower/upowerd
colord    1933     1  0 10月08 ?      00:00:00 /usr/lib/colord/colord
root      2393   905  0 10月08 ?      00:00:03 sshd: root@pts/8
root      2395     1  0 10月08 ?      00:00:00 /lib/systemd/systemd --user
root      2402  2395  0 10月08 ?      00:00:00 (sd-pam)
root      2478  2393  0 10月08 pts/8  00:00:00 -bash
root     13007     1  0 07:35 ?        00:00:00 /usr/sbin/cupsd -l
root     13008     1  0 07:35 ?        00:00:00 /usr/sbin/cups-browsed
robert   14474     1  0 17:23 ?        00:00:00 /lib/systemd/systemd --user
robert   14475 14474  0 17:23 ?        00:00:00 (sd-pam)
robert   14489     1  0 17:23 ?        00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --login
robert   14492  1598  0 17:23 ?        00:00:00 /sbin/upstart --user
robert   14518     1  0 17:23 ?        00:00:00 /usr/bin/VBoxClient --display
robert   14519 14518  0 17:23 ?        00:00:00 /usr/bin/VBoxClient --display
robert   14613     1  0 17:23 ?        00:00:00 /usr/bin/VBoxClient --seamless
robert   14639 14492  0 17:23 ?        00:00:00 upstart-udev-bridge --daemon --user
robert   14643 14492  0 17:23 ?        00:00:00 dbus-daemon --fork --session --address=unix:abstract=/tmp/dbus-VjW85Z2neA
robert   14655 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/hud/window-stack-bridge
robert   14683 14492  0 17:23 ?        00:00:00 upstart-file-bridge --daemon --user
robert   14684 14492  0 17:23 ?        00:00:00 upstart-dbus-bridge --daemon --session --user --bus-name session
robert   14685 14492  0 17:23 ?        00:00:00 upstart-dbus-bridge --daemon --system --user --bus-name system
robert   14692 14492  0 17:23 ?        00:00:00 /usr/bin/ibus-daemon --daemonize --xim --address unix:tmpdir=/tmp/ibus
robert   14710 14492  0 17:23 ?        00:00:00 /usr/lib/gvfs/gvfsd
robert   14715 14492  0 17:23 ?        00:00:00 /usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
robert   14718 14692  0 17:23 ?        00:00:00 /usr/lib/ibus/ibus-dconf
robert   14726 14692  0 17:23 ?        00:00:00 /usr/lib/ibus/ibus-ui-gtk3
robert   14730 14492  0 17:23 ?        00:00:00 /usr/lib/ibus/ibus-x11 --kill-daemon
robert   14737 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/bamf/bamfdaemon
robert   14742 14492  0 17:23 ?        00:00:00 /usr/lib/at-spi2-core/at-spi-bus-launcher
robert   14748 14742  0 17:23 ?        00:00:00 /usr/bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
robert   14751 14492  0 17:23 ?        00:00:00 /usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-session
robert   14763 14692  0 17:23 ?        00:00:00 /usr/lib/ibus/ibus-engine-simple
robert   14788 14492  0 17:23 ?        00:00:00 gpg-agent --homedir /home/robert/.gnupg --use-standard-socket --daemon
robert   14798 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/hud/hud-service
robert   14800 14492  0 17:23 ?        00:00:01 /usr/lib/unity-settings-daemon/unity-settings-daemon
robert   14814 14492  0 17:23 ?        00:00:00 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
robert   14822 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/unity/unity-panel-service
robert   14851 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/indicator-messages/indicator-messages-service
robert   14853 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/indicator-bluetooth/indicator-bluetooth-service
robert   14861 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/indicator-power/indicator-power-service
robert   14863 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/indicator-datetime/indicator-datetime-service
robert   14865 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/indicator-keyboard/indicator-keyboard-service --use-gtk
robert   14866 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/indicator-sound/indicator-sound-service
robert   14867 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/indicator-printers/indicator-printers-service
robert   14872 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/indicator-session/indicator-session-service
robert   14894 14492  0 17:23 ?        00:00:00 /usr/lib/x86_64-linux-gnu/indicator-application/indicator-application-service
robert   14914 14492  0 17:23 ?        00:00:00 /usr/lib/dconf/dconf-service
robert   14931 14492  0 17:23 ?        00:00:02 /usr/bin/pulseaudio --start --log-target=syslog
robert   14945 14492  0 17:23 ?        00:00:01 /usr/lib/evolution/evolution-source-registry
robert   14976 14814  0 17:24 ?        00:00:03 /usr/bin/gnome-software --gapplication-service
robert   14987 14492  0 17:24 ?        00:00:00 /usr/lib/evolution/evolution-calendar-factory
robert   14992 14814  0 17:24 ?        00:00:03 nautilus -n
robert   15000 14814  0 17:24 ?        00:00:00 nm-applet
robert   15002 14814  0 17:24 ?        00:00:00 /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1
robert   15023 14492  0 17:24 ?        00:00:00 /usr/bin/VBoxClient --seamless
robert   15037 14814  0 17:24 ?        00:00:00 /usr/lib/unity-settings-daemon/unity-fallback-mount-helper
robert   15046 14492  6 17:24 ?        00:12:15 compiz
robert   15052 14492  0 17:24 ?        00:00:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
root     15055     1  0 17:24 ?        00:00:00 /usr/lib/udisks2/udisksd --no-debug
robert   15091 14492  0 17:24 ?        00:00:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
robert   15106 14492  0 17:24 ?        00:00:00 /usr/lib/gvfs/gvfs-mtp-volume-monitor
robert   15109 14987  0 17:24 ?        00:00:00 /usr/lib/evolution/evolution-calendar-factory-subprocess --factory contacts --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.Calendarx14987x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/Calend
robert   15114 14492  0 17:24 ?        00:00:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
robert   15129 14492  0 17:24 ?        00:00:00 /usr/lib/gvfs/gvfs-goa-volume-monitor
robert   15132 14987  0 17:24 ?        00:00:00 /usr/lib/evolution/evolution-calendar-factory-subprocess --factory local --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.Calendarx14987x3 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/Calendar/
robert   15134 14492  0 17:24 ?        00:00:00 /usr/lib/evolution/evolution-addressbook-factory
robert   15155 15134  0 17:24 ?        00:00:00 /usr/lib/evolution/evolution-addressbook-factory-subprocess --factory local --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.AddressBookx15134x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/Add
robert   15178 14492  0 17:24 ?        00:00:00 /usr/lib/gvfs/gvfsd-trash --spawner :1.4 /org/gtk/gvfs/exec_spaw/0
robert   15263 14814  0 17:24 ?        00:00:00 zeitgeist-datahub
robert   15270 14492  0 17:24 ?        00:00:00 /bin/sh -c /usr/lib/x86_64-linux-gnu/zeitgeist/zeitgeist-maybe-vacuum; /usr/bin/zeitgeist-daemon
robert   15277 15270  0 17:24 ?        00:00:00 /usr/bin/zeitgeist-daemon
robert   15285 14492  0 17:24 ?        00:00:00 /usr/lib/x86_64-linux-gnu/zeitgeist-fts
robert   15357 14814  0 17:25 ?        00:00:00 update-notifier
robert   15382 14492  0 17:25 ?        00:00:06 /usr/bin/python3 /usr/bin/update-manager --no-update --no-focus-on-map
robert   15731 14814  0 17:26 ?        00:00:00 /usr/lib/x86_64-linux-gnu/deja-dup/deja-dup-monitor
robert   17840 14492  0 18:31 ?        00:00:00 /usr/lib/gnome-terminal/gnome-terminal-server
robert   17847 17840  0 18:31 pts/1    00:00:00 bash
robert   18234 14492  0 18:43 ?        00:00:00 /usr/lib/x86_64-linux-gnu/unity/unity-panel-service --lockscreen-mode
root     19493     2  0 19:28 ?        00:00:00 [kworker/1:1]
root     19770     2  0 19:38 ?        00:00:00 [kworker/u4:0]
root     20011     2  0 19:47 ?        00:00:01 [kworker/1:2]
root     20504     2  0 20:05 ?        00:00:00 [kworker/u4:2]
root     20506     2  0 20:05 ?        00:00:00 [kworker/0:2]
root     20743     2  0 20:14 ?        00:00:00 [kworker/0:0]
root     20950     2  0 20:21 ?        00:00:00 [kworker/u4:1]
root     20955     2  0 20:21 ?        00:00:00 [kworker/0:1]
root     20957     2  0 20:21 ?        00:00:00 [kworker/1:0]
root     21048  2478  0 20:25 pts/8    00:00:00 ps -ef
root@robert-Ubuntu:/dev# 
root@robert-Ubuntu:/dev# 
root@robert-Ubuntu:/dev# ps -ajx
 PPID   PID  PGID   SID TTY      TPGID STAT   UID   TIME COMMAND
    0     1     1     1 ?           -1 Ss       0   0:07 /sbin/init splash
    0     2     0     0 ?           -1 S        0   0:00 [kthreadd]
    2     4     0     0 ?           -1 I<       0   0:00 [kworker/0:0H]
    2     6     0     0 ?           -1 I<       0   0:00 [mm_percpu_wq]
    2     7     0     0 ?           -1 S        0   0:01 [ksoftirqd/0]
    2     8     0     0 ?           -1 I        0   6:49 [rcu_sched]
    2     9     0     0 ?           -1 I        0   0:00 [rcu_bh]
    2    10     0     0 ?           -1 S        0   0:00 [migration/0]
    2    11     0     0 ?           -1 S        0   0:01 [watchdog/0]
    2    12     0     0 ?           -1 S        0   0:00 [cpuhp/0]
    2    13     0     0 ?           -1 S        0   0:00 [cpuhp/1]
    2    14     0     0 ?           -1 S        0   0:01 [watchdog/1]
    2    15     0     0 ?           -1 S        0   0:00 [migration/1]
    2    16     0     0 ?           -1 S        0   0:31 [ksoftirqd/1]
    2    18     0     0 ?           -1 I<       0   0:00 [kworker/1:0H]
    2    19     0     0 ?           -1 S        0   0:00 [kdevtmpfs]
    2    20     0     0 ?           -1 I<       0   0:00 [netns]
    2    21     0     0 ?           -1 S        0   0:00 [rcu_tasks_kthre]
    2    22     0     0 ?           -1 S        0   0:00 [kauditd]
    2    24     0     0 ?           -1 S        0   0:00 [khungtaskd]
    2    25     0     0 ?           -1 S        0   0:00 [oom_reaper]
    2    26     0     0 ?           -1 I<       0   0:00 [writeback]
    2    27     0     0 ?           -1 S        0   0:00 [kcompactd0]
    2    28     0     0 ?           -1 SN       0   0:00 [ksmd]
    2    29     0     0 ?           -1 SN       0   0:00 [khugepaged]
    2    30     0     0 ?           -1 I<       0   0:00 [crypto]
    2    31     0     0 ?           -1 I<       0   0:00 [kintegrityd]
    2    32     0     0 ?           -1 I<       0   0:00 [kblockd]
    2    33     0     0 ?           -1 I<       0   0:00 [ata_sff]
    2    34     0     0 ?           -1 I<       0   0:00 [md]
    2    35     0     0 ?           -1 I<       0   0:00 [edac-poller]
    2    36     0     0 ?           -1 I<       0   0:00 [devfreq_wq]
    2    37     0     0 ?           -1 I<       0   0:00 [watchdogd]
    2    40     0     0 ?           -1 S        0   0:00 [kswapd0]
    2    41     0     0 ?           -1 I<       0   0:00 [kworker/u5:0]
    2    42     0     0 ?           -1 S        0   0:00 [ecryptfs-kthrea]
    2    85     0     0 ?           -1 I<       0   0:00 [kthrotld]
    2    86     0     0 ?           -1 I<       0   0:00 [acpi_thermal_pm]
    2    87     0     0 ?           -1 S        0   0:00 [scsi_eh_0]
    2    88     0     0 ?           -1 I<       0   0:00 [scsi_tmf_0]
    2    89     0     0 ?           -1 S        0   0:00 [scsi_eh_1]
    2    90     0     0 ?           -1 I<       0   0:00 [scsi_tmf_1]
    2    96     0     0 ?           -1 I<       0   0:00 [ipv6_addrconf]
    2   105     0     0 ?           -1 I<       0   0:00 [kstrp]
    2   122     0     0 ?           -1 I<       0   0:00 [charger_manager]
    2   162     0     0 ?           -1 S        0   0:00 [scsi_eh_2]
    2   163     0     0 ?           -1 I<       0   0:00 [scsi_tmf_2]
    2   166     0     0 ?           -1 I<       0   0:00 [kworker/0:1H]
    2   167     0     0 ?           -1 I<       0   0:02 [kworker/1:1H]
    2   189     0     0 ?           -1 S        0   0:00 [jbd2/sda1-8]
    2   190     0     0 ?           -1 I<       0   0:00 [ext4-rsv-conver]
    1   231   231   231 ?           -1 Ss       0   0:03 /lib/systemd/systemd-journald
    1   247   247   247 ?           -1 Ss       0   0:00 /lib/systemd/systemd-udevd
    2   344     0     0 ?           -1 I<       0   0:00 [iprt-VBoxWQueue]
    2   382     0     0 ?           -1 I<       0   0:00 [ttm_swap]
    1   633   633   633 ?           -1 Ss     106   0:04 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
    1   661   661   661 ?           -1 Ssl      0   0:03 /usr/sbin/NetworkManager --no-daemon
    1   662   662   662 ?           -1 Ss       0   0:00 /lib/systemd/systemd-logind
    1   666   666   666 ?           -1 Ssl      0   0:06 /usr/lib/accountsservice/accounts-daemon
    1   670   670   670 ?           -1 Ss     111   0:00 avahi-daemon: running [robert-Ubuntu.local]
    1   682   682   682 ?           -1 Ss       0   0:00 /usr/sbin/cron -f
    1   683   683   683 ?           -1 Ssl    104   0:00 /usr/sbin/rsyslogd -n
    1   706   706   706 ?           -1 Ss       0   0:00 /usr/sbin/acpid
  670   776   670   670 ?           -1 S      111   0:00 avahi-daemon: chroot helper
    1   812   812   812 ?           -1 Ss       0   0:10 /usr/sbin/irqbalance --pid=/var/run/irqbalance.pid
    1   905   905   905 ?           -1 Ss       0   0:00 /usr/sbin/sshd -D
    1   907   907   907 ?           -1 Ss       0   0:00 /usr/sbin/vsftpd /etc/vsftpd.conf
    1   921   921   921 ?           -1 Ssl      0   0:00 /usr/lib/policykit-1/polkitd --no-debug
    1   938   938   938 ?           -1 Ss       0   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
  938   939   938   938 ?           -1 S       33   0:00 nginx: worker process
  938   940   938   938 ?           -1 S       33   0:27 nginx: worker process
    1   960   960   960 ?           -1 Ssl    123   5:30 /usr/bin/redis-server 127.0.0.1:6379
  661   969   969   661 ?           -1 S        0   0:16 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /var/run/dhclient-enp0s9.pid -lf /var/lib/NetworkManager/dhclient-b61329b0-4973-32ee-ba8c-f7212a5fd39c-enp0s9.lease -cf /var/lib/NetworkManager/d
    1   985   985   985 ?           -1 SLsl     0   0:00 /usr/sbin/lightdm
  985   998   998   998 tty7       998 Ssl+     0   0:56 /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
  661  1000  1000   661 ?           -1 S        0   0:11 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /var/run/dhclient-enp0s8.pid -lf /var/lib/NetworkManager/dhclient-5e979922-23f3-3eaf-8f5f-2dd9d703628f-enp0s8.lease -cf /var/lib/NetworkManager/d
  661  1001  1001   661 ?           -1 S        0   0:11 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /var/run/dhclient-enp0s3.pid -lf /var/lib/NetworkManager/dhclient-f1d56f04-8693-3fff-9b39-2ee4adc5b39e-enp0s3.lease -cf /var/lib/NetworkManager/d
  661  1062  1062   661 ?           -1 S    65534   0:00 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/var/run/NetworkManager/dnsmasq.pid --listen-address=127.0.1.1 --cache-size=0 --conf-file=/dev/null --proxy-dnssec --enabl
    1  1459  1459  1459 ?           -1 Ssl    109   0:00 /usr/bin/whoopsie -f
    1  1475  1475  1475 tty1      1475 Ss+      0   0:00 /sbin/agetty --noclear tty1 linux
  985  1598   985   985 ?           -1 Sl       0   0:00 lightdm --session-child 12 19
    1  1852  1852  1852 ?           -1 SNsl   118   0:03 /usr/lib/rtkit/rtkit-daemon
    1  1919  1919  1919 ?           -1 Ssl      0   0:03 /usr/lib/upower/upowerd
    1  1933  1933  1933 ?           -1 Ssl    113   0:00 /usr/lib/colord/colord
  905  2393  2393  2393 ?           -1 Rs       0   0:03 sshd: root@pts/8
    1  2395  2395  2395 ?           -1 Ss       0   0:00 /lib/systemd/systemd --user
 2395  2402  2395  2395 ?           -1 S        0   0:00 (sd-pam)
 2393  2478  2478  2478 pts/8    21053 Ss       0   0:00 -bash
    1 13007 13007 13007 ?           -1 Ss       0   0:00 /usr/sbin/cupsd -l
    1 13008 13008 13008 ?           -1 Ssl      0   0:00 /usr/sbin/cups-browsed
    1 14474 14474 14474 ?           -1 Ss    1000   0:00 /lib/systemd/systemd --user
14474 14475 14474 14474 ?           -1 S     1000   0:00 (sd-pam)
    1 14489 14488 14488 ?           -1 Sl    1000   0:00 /usr/bin/gnome-keyring-daemon --daemonize --login
 1598 14492 14492 14492 ?           -1 Ss    1000   0:00 /sbin/upstart --user
    1 14518 14516 14516 ?           -1 S     1000   0:00 /usr/bin/VBoxClient --display
14518 14519 14516 14516 ?           -1 S     1000   0:00 /usr/bin/VBoxClient --display
    1 14613 14612 14612 ?           -1 S     1000   0:00 /usr/bin/VBoxClient --seamless
14492 14639 14636 14636 ?           -1 S     1000   0:00 upstart-udev-bridge --daemon --user
14492 14643 14643 14643 ?           -1 Ss    1000   0:00 dbus-daemon --fork --session --address=unix:abstract=/tmp/dbus-VjW85Z2neA
14492 14655 14655 14655 ?           -1 Ss    1000   0:00 /usr/lib/x86_64-linux-gnu/hud/window-stack-bridge
14492 14683 14682 14682 ?           -1 S     1000   0:00 upstart-file-bridge --daemon --user
14492 14684 14681 14681 ?           -1 S     1000   0:00 upstart-dbus-bridge --daemon --session --user --bus-name session
14492 14685 14680 14680 ?           -1 S     1000   0:00 upstart-dbus-bridge --daemon --system --user --bus-name system
14492 14692 14692 14692 ?           -1 Ssl   1000   0:00 /usr/bin/ibus-daemon --daemonize --xim --address unix:tmpdir=/tmp/ibus
14492 14710 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/gvfs/gvfsd
14492 14715 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
14692 14718 14692 14692 ?           -1 Sl    1000   0:00 /usr/lib/ibus/ibus-dconf
14692 14726 14692 14692 ?           -1 Sl    1000   0:00 /usr/lib/ibus/ibus-ui-gtk3
14492 14730 14692 14692 ?           -1 Sl    1000   0:00 /usr/lib/ibus/ibus-x11 --kill-daemon
14492 14737 14737 14737 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/bamf/bamfdaemon
14492 14742 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/at-spi2-core/at-spi-bus-launcher
14742 14748 14643 14643 ?           -1 S     1000   0:00 /usr/bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
14492 14751 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-session
14692 14763 14692 14692 ?           -1 Sl    1000   0:00 /usr/lib/ibus/ibus-engine-simple
14492 14788 14788 14788 ?           -1 Ss    1000   0:00 gpg-agent --homedir /home/robert/.gnupg --use-standard-socket --daemon
14492 14798 14798 14798 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/hud/hud-service
14492 14800 14800 14800 ?           -1 Ssl   1000   0:01 /usr/lib/unity-settings-daemon/unity-settings-daemon
14492 14814 14814 14814 ?           -1 Ssl   1000   0:00 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
14492 14822 14822 14822 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/unity/unity-panel-service
14492 14851 14851 14851 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/indicator-messages/indicator-messages-service
14492 14853 14853 14853 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/indicator-bluetooth/indicator-bluetooth-service
14492 14861 14861 14861 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/indicator-power/indicator-power-service
14492 14863 14863 14863 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/indicator-datetime/indicator-datetime-service
14492 14865 14865 14865 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/indicator-keyboard/indicator-keyboard-service --use-gtk
14492 14866 14866 14866 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/indicator-sound/indicator-sound-service
14492 14867 14867 14867 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/indicator-printers/indicator-printers-service
14492 14872 14872 14872 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/indicator-session/indicator-session-service
14492 14894 14894 14894 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/indicator-application/indicator-application-service
14492 14914 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/dconf/dconf-service
14492 14931 14927 14927 ?           -1 S<l   1000   0:02 /usr/bin/pulseaudio --start --log-target=syslog
14492 14945 14643 14643 ?           -1 Sl    1000   0:01 /usr/lib/evolution/evolution-source-registry
14814 14976 14814 14814 ?           -1 SLl   1000   0:03 /usr/bin/gnome-software --gapplication-service
14492 14987 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/evolution/evolution-calendar-factory
14814 14992 14814 14814 ?           -1 Sl    1000   0:03 nautilus -n
14814 15000 14814 14814 ?           -1 Sl    1000   0:00 nm-applet
14814 15002 14814 14814 ?           -1 Sl    1000   0:00 /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1
14492 15023 15020 15020 ?           -1 S     1000   0:00 /usr/bin/VBoxClient --seamless
14814 15037 14814 14814 ?           -1 Sl    1000   0:00 /usr/lib/unity-settings-daemon/unity-fallback-mount-helper
14492 15046 15046 15046 ?           -1 Ssl   1000  12:15 compiz
14492 15052 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
    1 15055 15055 15055 ?           -1 Ssl      0   0:00 /usr/lib/udisks2/udisksd --no-debug
14492 15091 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
14492 15106 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/gvfs/gvfs-mtp-volume-monitor
14987 15109 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/evolution/evolution-calendar-factory-subprocess --factory contacts --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.Calendarx14987x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Backe
14492 15114 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
14492 15129 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/gvfs/gvfs-goa-volume-monitor
14987 15132 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/evolution/evolution-calendar-factory-subprocess --factory local --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.Calendarx14987x3 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/
14492 15134 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/evolution/evolution-addressbook-factory
15134 15155 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/evolution/evolution-addressbook-factory-subprocess --factory local --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.AddressBookx15134x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Ba
14492 15178 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/gvfs/gvfsd-trash --spawner :1.4 /org/gtk/gvfs/exec_spaw/0
14814 15263 14814 14814 ?           -1 Sl    1000   0:00 zeitgeist-datahub
14492 15270 14643 14643 ?           -1 S     1000   0:00 /bin/sh -c /usr/lib/x86_64-linux-gnu/zeitgeist/zeitgeist-maybe-vacuum; /usr/bin/zeitgeist-daemon
15270 15277 14643 14643 ?           -1 Sl    1000   0:00 /usr/bin/zeitgeist-daemon
14492 15285 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/x86_64-linux-gnu/zeitgeist-fts
14814 15357 14814 14814 ?           -1 Sl    1000   0:00 update-notifier
14492 15382 14814 14814 ?           -1 SNl   1000   0:06 /usr/bin/python3 /usr/bin/update-manager --no-update --no-focus-on-map
14814 15731 14814 14814 ?           -1 Sl    1000   0:00 /usr/lib/x86_64-linux-gnu/deja-dup/deja-dup-monitor
14492 17840 14643 14643 ?           -1 Sl    1000   0:00 /usr/lib/gnome-terminal/gnome-terminal-server
17840 17847 17847 17847 pts/1    17847 Ss+   1000   0:00 bash
14492 18234 18234 18234 ?           -1 Ssl   1000   0:00 /usr/lib/x86_64-linux-gnu/unity/unity-panel-service --lockscreen-mode
    2 19493     0     0 ?           -1 I        0   0:00 [kworker/1:1]
    2 19770     0     0 ?           -1 I        0   0:00 [kworker/u4:0]
    2 20011     0     0 ?           -1 I        0   0:01 [kworker/1:2]
    2 20504     0     0 ?           -1 I        0   0:00 [kworker/u4:2]
    2 20506     0     0 ?           -1 I        0   0:00 [kworker/0:2]
    2 20743     0     0 ?           -1 I        0   0:00 [kworker/0:0]
    2 20950     0     0 ?           -1 I        0   0:00 [kworker/u4:1]
    2 20955     0     0 ?           -1 I        0   0:00 [kworker/0:1]
    2 20957     0     0 ?           -1 I        0   0:00 [kworker/1:0]
 2478 21053 21053  2478 pts/8    21053 R+       0   0:00 ps -ajx
root@robert-Ubuntu:/dev# 

# 在视图函数中执行如下代码就可通过 ps -eLf 抓到线程
t = threading.Thread(target=dispatcher_flow, args=(name, age))
t.start()

root@robert-Ubuntu:~# ps -eLf | grep man
UID        PID  PPID   LWP  C NLWP STIME TTY          TIME CMD
root       122     2   122  0    1 19:19 ?        00:00:00 [charger_manager]
root      2280  2202  2280  0    1 19:35 pts/8    00:00:00 python manage.py runserver 0.0.0.0:8082
root      2295  2280  2295  5    3 19:37 pts/8    00:00:09 /usr/bin/python manage.py runserver 0.0.0.0:8082
root      2295  2280  2297  0    3 19:37 pts/8    00:00:00 /usr/bin/python manage.py runserver 0.0.0.0:8082
root      2295  2280  2338  0    3 19:39 pts/8    00:00:00 /usr/bin/python manage.py runserver 0.0.0.0:8082
root      2342  2309  2342  0    1 19:39 pts/9    00:00:00 grep --color=auto man
root@robert-Ubuntu:~# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/236237
推荐阅读
相关标签
  

闽ICP备14008679号