How to create a CPU spike with a bash command

后端 未结 23 1245
小蘑菇
小蘑菇 2020-11-30 16:11

I want to create a near 100% load on a Linux machine. It\'s quad core system and I want all cores going full speed. Ideally, the CPU load would last a designated amount of

23条回答
  •  孤街浪徒
    2020-11-30 16:30

    I went through the Internet to find something like it and found this very handy cpu hammer script.

    #!/bin/sh
    
    # unixfoo.blogspot.com
    
    if [ $1 ]; then
        NUM_PROC=$1
    else
        NUM_PROC=10
    fi
    
    for i in `seq 0 $((NUM_PROC-1))`; do
        awk 'BEGIN {for(i=0;i<10000;i++)for(j=0;j<10000;j++);}' &
    done
    

提交回复
热议问题