How to set CPU load on a Red Hat Linux box? How to set CPU load on a Red Hat Linux box? linux linux

How to set CPU load on a Red Hat Linux box?


This is exactly what you need (internet archive link):https://web.archive.org/web/20120512025754/http://weather.ou.edu/~apw/projects/stress/stress-1.0.4.tar.gz

From the homepage:"stress is a simple workload generator for POSIX systems. It imposes a configurable amount of CPU, memory, I/O, and disk stress on the system. It is written in C, and is free software licensed under the GPL."


Find a simple prime number search program that has source code. Modify the source code to add a nanosleep call to the main loop with whichever delay gives you the desired CPU load.


One common way to get some load on a system is to compile a large software package over and over again. Something like the Linux kernel.

Get a copy of the source code, extract the tar.bz2, go into the top level source directory, copy your kernel config from /boot to .config or zcat /proc/config.gz > .config, the do make oldconfig, then while true; do make clean && make bzImage; done

If you have an SMP system, then make -j bzImage is fun, it will spawn make tasks in parallel.

One problem with this is adjusting the CPU load. It will be a maximum CPU load except for when waiting on disk I/O.