-->
当前位置:首页 > DayDayUp > 正文内容

linux 查看进程启动路径

Luz3年前 (2021-10-12)DayDayUp3753

linux下top查询进程一般显示这样,看不到全路径

Tasks: 290 total,   1 running, 216 sleeping,   0 stopped,   1 zombie
%Cpu(s):  1.2 us,  2.3 sy,  0.0 ni, 96.2 id,  0.0 wa,  0.0 hi,  0.2 si,  0.0 st
KiB Mem :  8152588 total,  4136244 free,  1830672 used,  2185672 buff/cache
KiB Swap:   998908 total,   994032 free,     4876 used.  5863860 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                                            
 1628 root      20   0 1601960 197860 105968 S   2.3  2.4   3:29.15 dockerd                                                                                                                                                                            
 9460 root      20   0  714344  14780   7692 S   1.7  0.2   1:14.98 docker-gen                                                                                                                                                                         
 7492 root      20   0  109520   7636   6172 S   1.3  0.1   0:00.28 sshd                                                                                                                                                                               
 8254 root      20   0   40648   3968   3188 R   0.7  0.0   0:00.07 top                                                                                                                                                                                
   10 root      20   0       0      0      0 I   0.3  0.0   0:26.04 rcu_sched                                                                                                                                                                          
  532 root      20   0   35392   6512   6144 S   0.3  0.1   0:04.89 systemd-journal                                                                                                                                                                    
  591 root      20   0  103260  78532   5252 S   0.3  1.0   0:06.08 gunicorn                                                                                                                                                                           
 1621 root      20   0  116460  17924   9856 S   0.3  0.2   3:25.54 nps                                                                                                                                                                                
 2100 snmp      20   0   59080   9084   4068 S   0.3  0.1   1:38.20 snmpd                                                                                                                                                                              
 5639 999       20   0 2776968 100108  22132 S   0.3  1.2   0:14.07 mysqld                                                                                                                                                                             
 5844 999       20   0   34120   4204   3256 S   0.3  0.1   0:18.99 redis-server                                                                                                                                                                       
 7655 root      20   0   41360   4448   2892 S   0.3  0.1   0:00.13 top                                                                                                                                                                                
31765 root      20   0  752092  16392   5452 S   0.3  0.2   1:51.75 BT-Task                                                                                                                                                                            
32357 root      20   0   25096  22728   7400 S   0.3  0.3   0:03.49 gunicorn                                                                                                                                                                           
    1 root      20   0  185712   6416   4096 S   0.0  0.1   0:19.67 systemd                                                                                                                                                                            
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.04 kthreadd                                                                                                                                                                           
    3 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 rcu_gp                                                                                                                                                                             
    4 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 rcu_par_gp                                                                                                                                                                         
    6 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/0:0H-kb                                                                                                                                                                    
    8 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 mm_percpu_wq                                                                                                                                                                       
    9 root      20   0       0      0      0 S   0.0  0.0   0:00.65 ksoftirqd/0                                                                                                                                                                        
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.09 migration/0                                                                                                                                                                        
   12 root     -51   0       0      0      0 S   0.0  0.0   0:00.00 idle_inject/0                                                                                                                                                                      
   14 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/0                                                                                                                                                                            
   15 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/1                                                                                                                                                                            
   16 root     -51   0       0      0      0 S   0.0  0.0   0:00.00 idle_inject/1                                                                                                                                                                      
   17 root      rt   0       0      0      0 S   0.0  0.0   0:00.09 migration/1                                                                                                                                                                        
   18 root      20   0       0      0      0 S   0.0  0.0   0:01.96 ksoftirqd/1

每个进程启动之后在 /proc下面有一个于pid对应的路径
ps -ef|grep python
显示:oracle    4431  4366  0 18:56 pts/2    00:00:00 python Server.py
4431就是进程号
到/proc/4431下,ls -l 会看到:
总用量 0
-r--r--r--    1 oracle   oinstall        0 12月 29 18:58 cmdline
lrwxrwxrwx    1 oracle   oinstall        0 12月 29 18:58 cwd -> /XXX/ultserver_aa
-r--------    1 oracle   oinstall        0 12月 29 18:58 environ
lrwxrwxrwx    1 oracle   oinstall        0 12月 29 18:58 exe -> /usr/bin/python2.4
dr-x------    2 oracle   oinstall        0 12月 29 18:58 fd
-r--------    1 oracle   oinstall        0 12月 29 18:58 maps
-rw-------    1 oracle   oinstall        0 12月 29 18:58 mem
-r--r--r--    1 oracle   oinstall        0 12月 29 18:58 mounts
lrwxrwxrwx    1 oracle   oinstall        0 12月 29 18:58 root -> /
-r--r--r--    1 oracle   oinstall        0 12月 29 18:58 stat
-r--r--r--    1 oracle   oinstall        0 12月 29 18:58 statm
-r--r--r--    1 oracle   oinstall        0 12月 29 18:58 status

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。