Skip to content

Instantly share code, notes, and snippets.

@suziewong suziewong/load.sh
Created Aug 16, 2013

Embed
What would you like to do?
如何使用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
You can’t perform that action at this time.