Operations 5 min read

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.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Stress Test CPU on Linux Using stress and mpstat

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 stress

Usage: 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 60s

mpstat command

Install the sysstat package, which provides mpstat:

sudo apt-get install sysstat
sudo yum install sysstat

Usage: -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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Performance MonitoringLinuxmpstatCPU stress teststress command
Liangxu Linux
Written by

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

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.