1

When I run ps -f -u $USER ($USER is ubuntu) this is the output I get.

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
ubuntu   23517  0.0  0.1  22244  4856 pts/5    Ss+  04:00   0:00 /bin/bash
ubuntu   21705  0.0  0.1  22364  4988 pts/7    Ss   03:05   0:00 /bin/bash
ubuntu   29771  0.0  0.0   5956   620 pts/7    S+   04:46   0:00  \_ tail -f /home/ubuntu/logs/cron-20150313.log
ubuntu   21681  0.0  0.0  21288  3764 pts/6    Ss   03:03   0:00 -bash
ubuntu   21703  0.0  0.0  25648  1120 pts/6    S+   03:05   0:00  \_ screen
ubuntu   21611  0.0  0.0  21264  3728 pts/3    Ss   03:02   0:00 /bin/bash
ubuntu   21690  0.0  0.0  21328  3788 pts/3    S+   03:03   0:00  \_ bash --login
ubuntu   20944  0.0  0.1  22228  4840 pts/0    Ss+  00:04   0:00 /bin/bash
ubuntu   20400  0.0  0.1  22320  4944 pts/1    Ss+  Mar12   0:00 /bin/bash
ubuntu    5194  0.0  0.0  22212  3600 pts/2    Ss    2014   0:00 /bin/bash
ubuntu   20841  0.0  0.0   5956   620 pts/2    S+   Mar12   0:00  \_ tail -f job.log
ubuntu    1931  0.0  0.1  34748  7568 pts/2    S    Jan13   0:00 /usr/bin/python /usr/local/bin/pynt start_job
ubuntu    1933  0.0  0.0   4444   184 pts/2    S    Jan13   0:00  \_ /bin/sh -c python -m job_manager pdf
ubuntu    1935  2.5  0.4  65380 18708 pts/2    S    Jan13 2162:55      \_ python -m job_manager pdf

It basically shows a tree structure of the processes hierarchy.

However if I just run the same command line in my bash shell, I get this

UID        PID  PPID  C STIME TTY          TIME CMD
ubuntu    1931     1  0 Jan13 pts/2    00:00:00 /usr/bin/python /usr/local/bin/pynt start_job
ubuntu    1933  1931  0 Jan13 pts/2    00:00:00 /bin/sh -c python -m job_manager pdf
ubuntu    1935  1933  2 Jan13 pts/2    1-12:02:56 python -m job_manager pdf
ubuntu    5193     1  0  2014 ?        00:00:01 SCREEN
ubuntu    5194  5193  0  2014 pts/2    00:00:00 /bin/bash
ubuntu   20400  5193  0 Mar12 pts/1    00:00:00 /bin/bash
ubuntu   20841  5194  0 Mar12 pts/2    00:00:00 tail -f job.log
ubuntu   20944  5193  0 00:01 pts/0    00:00:00 /bin/bash
ubuntu   21611  5193  0 02:59 pts/3    00:00:00 /bin/bash
ubuntu   21680 21627  0 03:00 ?        00:00:01 sshd: ubuntu@pts/6  
ubuntu   21681 21680  0 03:00 pts/6    00:00:00 -bash
ubuntu   21690 21611  0 03:00 pts/3    00:00:00 bash --login
ubuntu   21703 21681  0 03:02 pts/6    00:00:00 screen
ubuntu   21704 21703  0 03:02 ?        00:00:01 SCREEN
ubuntu   21705 21704  0 03:02 pts/7    00:00:01 /bin/bash
ubuntu   23517 21704  0 03:57 pts/5    00:00:00 /bin/bash
ubuntu   31407 21705  0 04:58 pts/7    00:00:00 ps -f -u ubuntu

I have double-checked and I did not have any alias of ps. In both case they are running /bin/ps

Why the difference in the output?

2
  • I don't know why it's so, but the command for tree-like display is actually f, not -f: ps f -u ubuntu. f is for forest, -f for full-format listing.
    – muru
    Mar 13, 2015 at 5:08
  • In the cronjob I actually put ps -f -u $USER. Because $USER is empty in cron's content, it becomes ps -f -u and shows tree output. Very inconsistent. Mar 13, 2015 at 5:28

0

You must log in to answer this question.

Browse other questions tagged .