18

So the system I'm working on (BusyBox) has a ps that takes no command line arguments and pidof returns nothing even though it exists within /sbin and points to killall5.

Another issue I had is that top takes no -H, but you can hit h (not H) in top to view the individual threads.

Any tips on how I can generate a list of all PID's under a given process name?

terdon
  • 234,489
  • 66
  • 447
  • 667
Madau
  • 181
  • 1
  • 1
  • 3

2 Answers2

20

In case you have limited find (no -printf option):

find /proc -mindepth 2 -maxdepth 2 -name exe -exec ls -lh {} \; 2>/dev/null 
Virus_7
  • 301
  • 2
  • 3
  • 1
    Thanks! Extension to display command line for each process too: `find /proc -mindepth 2 -maxdepth 2 -name exe -exec ls -lh {} \; -exec sh -c 'echo -n cmdline: ; cat "${0%exe}cmdline" | xargs -0 echo ; echo' {} \;` by also looking at `/proc//cmdline` as well as `/proc//exe` (note: not perfect, some quotes may be missing from command line args) – sparrowt Jan 27 '22 at 11:49
2

Looking for bash:

find /proc -mindepth 2 -maxdepth 2 -name exe -lname '*/bash' \
    -printf %h\\n 2>/dev/null | 
sed s+^/proc/++
Hauke Laging
  • 88,146
  • 18
  • 125
  • 174
  • Hey, so I think this is getting really close to what I'm looking for, but the version of find I'm working with does not have `-lname` as a possible expression. – Madau Feb 19 '14 at 16:26