How to create a CPU spike with a bash command

后端 未结 23 1223
小蘑菇
小蘑菇 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 16:46

    Although I'm late to the party, this post is among the top results in the google search "generate load in linux".

    The result marked as solution could be used to generate a system load, i'm preferring to use sha1sum /dev/zero to impose a load on a cpu-core.

    The idea is to calculate a hash sum from an infinite datastream (eg. /dev/zero, /dev/urandom, ...) this process will try to max out a cpu-core until the process is aborted. To generate a load for more cores, multiple commands can be piped together.

    eg. generate a 2 core load: sha1sum /dev/zero | sha1sum /dev/zero

提交回复
热议问题