Linux 4 All

Best Linux tricks source

Posts in the awk category

Get mail queue

When dealing with mail issues, the following one-liner will display all Postfix mail IDs from the queue.

postqueue -p | egrep -v ^[[:space:]] | grep -v ^$ | awk '{print $1}' | grep -v ^\( | grep -v ^\- | sed -e 's/\*//g'

The following one-liner will display number of Apache PIDs and sort them after memory usage:

ps aux | awk '$11 ~ /httpd/ {c++; SUM +=$6; print $6/1024" MB, PID:", $2|"sort -rn| head"} END {print c" Total Apache Processes"} END {print SUM/1024" MB Total Memory"} END {print "Top 10 Memory users:"}'