How to Stress Test CPU on Linux Using stress and mpstat
This guide explains how to perform CPU stress testing on Linux by installing and using the stress and mpstat commands, detailing installation steps, command options, example executions, and how to interpret their output to assess system performance and stability.
In Linux environments, CPU stress testing evaluates load capacity and stability. Two common commands are stress and mpstat.
stress command
Install:
sudo apt-get install stress sudo yum install stressUsage: specify the number of CPU workers with -c <number> and the test duration with -t <time>. stress -c 4 -t 60 The command runs four CPU workers for 60 seconds and produces output such as:
stress: info: [8640] dispatching hogs: 4 cpu, 0 io, 0 vm, 0 hdd
stress: info: [8640] successful run completed in 60smpstat command
Install the sysstat package, which provides mpstat:
sudo apt-get install sysstat sudo yum install sysstatUsage: -P ALL monitors all CPUs; you can set the interval and count, e.g., mpstat -P ALL 5 3 to report every 5 seconds three times. mpstat -P ALL 5 3 Sample output shows overall and per‑CPU utilization percentages for user, system, iowait, and idle time, allowing analysis of CPU performance and stability.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
