cpu压测

  • 内容
  • 相关
cpu压测,执行脚本cpu使用率跑满
vim cpupm.sh
#!/bin/sh
PWD=$(cd $(dirname $0); pwd)
cpu_num=$1

if [ $# != 1 ]
then
  printf "\e[0;34mUSAGE: $0 <CPUs>\e[0m\n"
  exit 1
fi

for i in $(seq ${cpu_num})
do
    echo -ne "
    i=0;
while true
do
    i=i+1;
done" | /bin/sh &
    pid_array[${i}]=$! ;
done

for i in "${pid_array[@]}"; do
    printf "\e[0;32mkill ${i}\e[0m\n" >> ${PWD}/kill_cpu_up.log 2>&1
done

sh cpupm.sh 4


本文标签:

版权声明:若无特殊注明,本文皆为《技术张儿》原创,转载请保留文章出处。

本文链接:cpu压测 - http://poweroff.cn/bash/393.html