Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a RHEL box that I need to put under a moderate and variable amount of CPU load (50%-75%).

What is the best way to go about this? Is there a program that can do this that I am not aware of? I am happy to write some C code to make this happen, I just don't know what system calls will help.

like image 262
salt.racer Avatar asked Sep 26 '08 20:09

salt.racer


2 Answers

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."

like image 64
Tom Feiner Avatar answered Sep 28 '22 02:09

Tom Feiner


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.

like image 35
Zan Lynx Avatar answered Sep 28 '22 02:09

Zan Lynx