How can I find the total memory usage of all processes (including child processes) with PPID of 1. For a program like nginx/httpd which forks several child processes, ps/top gives the memory usage of each process separately. I want to know the total memory usage of nginx/apache instead of the individual child processes.


If you want something interactive, try :

atop - launch it and press 'm' (memory usage) and 'p' (group by process name).

If you want something scriptable, there's something a bit like the below - although it's not doing quite what you've asked for (PPID 1), but you can group based on e.g. process name using awk -

ps -eo pmem,vsize,cmd | grep -v '\[' | awk 'NR>2{mem[$3]+=$2}END {for(k in mem) print k " " mem[k]/1024000};' | sort -gk 2 | tail -n 10

There's probably some clever way to filter on ppid with the ps... but I'm too stupid to figure it out quickly.

| improve this answer | |
  • Also, pressing 'a' will show all processes, instead of just active ones. – LHLaurini Jan 13 at 17:52

On a distro using systemd, systemd-cgls should show memory usage per service. Doesn't always obtain the information though.

| improve this answer | |
  • Thanks. The server is running CentOS 6, so there is no systemd. I have added the centos-6 tag to the question. – Joyce Babu Jan 18 '15 at 5:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.