LLI Wiki — My Digital Knowledge Base

Load all CPU cores on Linux with yes and gzip

Bash script that loads all CPU cores for one minute with yes and gzip, to test load on Linux.

This Bash script loads all CPU cores for 60 seconds by starting one yes | gzip pipeline per core. It can be used to test CPU load on a machine or to check how a monitoring tool reacts to it.

#!/bin/bash
# Définir le nombre de threads correspondant au nombre de cœurs du processeur
threads=$(nproc)

# Lancer des tâches yes gzip sur tous les threads
for ((i=0; i<threads; i++))
do
    yes | gzip > /dev/null &
done

# Attendre une certaine durée de temps
sleep 60

# Terminer les tâches yes gzip
killall yes

How it works

Mastodon LLIMastodon SocialFosstodon