Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm look for shell script to send Top processes as an email when Monitor CPU load average exceed 20 I'm running RedHat 6.

share|improve this question
uptime | awk '$NF >= 20 { system("top -cSb n 1") }' \
    | tail -n +8 | sort -rn -k11 | head \
        | mail -s "PROBLEM Service Alert: load_fifteen is CRITICAL" email@domain
  • NF stands for Number of Fields. $NF get the value of the last field. This is the system load average for past 15 minutes
  • top -b to run in batch mode, for sending output to stdout
  • tail -n +8 | sort -rn -k11 | head: remove the headers, then sort by CPU Time, and get the top processes.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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