Getting amount of memory processes usage from 'ps aux' output with awk in MB
Question
I`m newbie with Linux so... I have a exercise to do: using only ps, grep, awk, gawk determine total amount of memory processes used by SQL. How i can determine with ps how much memory used by any process? Mem in ps displaying in percents... Thanks alot.
Solution
ps auwx | awk '/[s]ql/ {total += $4} END {print total}'
You might want to look for $11 ~ /sql/
instead to find actual (my)sql processes instead of any command with "sql" in any argument.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow