0

I'm trying to report on running processes in Yocto (Poky). ps aux doesn't work here, but standard ps call return much of what aux would in Debian. But it won't report my .sh script processes. Is there an argument that works here, or another call I can try? Thanks in advance.

geotheory
  • 22,624
  • 29
  • 119
  • 196
  • Well, Dan told you have to get the full `ps` into your image. Though, busybox `ps` should list all your processes. Are you sure that the processes you think are missing really was running during your test? I've just verified that I'm seeing all my processes here. – Anders Dec 10 '15 at 08:54
  • Definitely doesn't detect it. If I create a basic [`while true`](http://pastebin.com/d0inB42k) loop script, `chmod 755` then run with amperand `&`, then search for it with `ps | grep test_abc.sh` it only reports the grep call itself.. – geotheory Dec 10 '15 at 18:29
  • I'm check it tomorrow then. Though both ps and the busybox ps då travel /proc/, so as long as your process actually exists, it should show up. – Anders Dec 10 '15 at 18:37
  • Well, there's one thing I can think of. It could be that as you're running the process in the background, a new process (shell) is started, and the script make is lost. I assume that you at least can see the shell process that your script is running in? – Anders Dec 10 '15 at 18:59
  • Can't find the bash - at least the bash instances I find don't look like this. However I do find the `sleep 100` line, which suggests `ps` is finding the outputs of `*.sh` but not the script itself. – geotheory Dec 10 '15 at 19:07
  • Ha, when I kill those sleep processes they automatically regenerate! – geotheory Dec 10 '15 at 19:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/97554/discussion-between-geotheory-and-anders). – geotheory Dec 10 '15 at 19:44

2 Answers2

2

You are probably using busybox. Busybox contains its own version of ps and might not have support for the flags you're using. A simple ls -l /bin/ps should give you indications whether or not it's symlinked to busybox or not.

My suggestion would be to include the package procps in your recipe (which contains the ps you're more familiar with).

  • You're right I see `/bin/busybox.nosuid`. Is there another solution? The project I'm working on is pretty much stuck with Poky. – geotheory Dec 10 '15 at 18:23
2

Busybox ps should show you all your processes.

I've created this test script, pstest.sh:

#!/bin/sh

while true; do
        sleep 10;
done

Which I've been running, both on a Debian box, aon a qemux86 based core-image-minimal, and on a custom embedded device built with OpenEmbedded / Yocto. (I.e. the last one is not running the Yocto kernel). On all of these devices, the following holds true:

 # ./pstest.sh &
 # ps 
  PID USER       VSZ STAT COMMAND
    1 root      4196 S    {systemd} /sbin/init
    2 root         0 SW   [kthreadd]
    3 root         0 SW   [ksoftirqd/0]
    5 root         0 SW<  [kworker/0:0H]
.....
  633 root      2452 S    {pstest.sh} /bin/sh ./pstest.sh
  634 root      2732 S    sleep 10
  638 root      3044 R    ps

As you can see, I'm seeing the script process, as well as the sleep command. (Note: on Debian ps above has been replaced with busybox ps). If you still can only see the sleep, could you try the following:

# cat /proc/`pidof sleep`/status | grep PPid
PPid:   633

By running that line, you should be able to see the parent PID of the sleep command; check which process that corresponds to.

Anders
  • 8,541
  • 1
  • 27
  • 34
  • Hmm I get a few lies with e.g. `cat: can't open '1408': No such file or directory` - http://pastebin.com/fV1M1VHz – geotheory Dec 11 '15 at 12:21