shell脚本统计httpd进程和子进程占用的CPU、内存大小,要求每隔5s统计一次

#!/bin/bash
while true
do
echo "CPU占用为"
ps -aux | grep httpd | grep  'apache' | awk '{print $3}' | awk '{sum += $1};END {print sum}'
echo "内存为(M)"
ps -aux | grep httpd | grep  'apache' | awk '{print $4}' | awk '{sum += $1};END {print sum}'
sleep 5s
done

你可能感兴趣的:(linux,shell,cpu,bash)