Often I have to test Linux systems to see how do they work when they have an high CPU load.
To generate High CPU load (100%) I've written a small shell script and then I generalized it to work fine on multi core architectures.
The CPU consuming function uses dd to get data from the /dev/urandom device
and then uses gzip to make some CPU intensive job. Such a function is mono thread, so it generates 100% load on a single core. To generate 100% load on a multicore architecture, the script has to create multiple instances of the CPU consuming function. The script accept has input parameter the number of CPU consuming functions it has to launch..
The source code for the script is the following one:
save the script as you like, since I have a lot of fantasy, I named it cpuLoad.sh. Then run
This makes the script executable.
then run the script issuing the command