Skip to content

Instantly share code, notes, and snippets.

@suziewong
Created August 16, 2013 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suziewong/6248672 to your computer and use it in GitHub Desktop.
Save suziewong/6248672 to your computer and use it in GitHub Desktop.
如何使用Shell缉拿问题进程 http://huoding.com/2013/01/30/225
#/bin/bash
LOAD=$(awk '{print $1}' /proc/loadavg)
CPUNUM=$(grep -c processor /proc/cpuinfo)
if [ $(echo "$LOAD > $CPUNUM" | bc) = 1 ]; then
RESULT=$(ps -eo pcpu,pmem,user,args | awk '$1 > 0' | sort -nr)
if [ -n "$RESULT" ]; then
echo "$RESULT" > /var/log/ps.$(date +"%Y%m%d%H%M")
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment