Skip to content

Instantly share code, notes, and snippets.

@stackdump
Created January 27, 2015 21:36
Show Gist options
  • Save stackdump/08bf607e9eb29327988e to your computer and use it in GitHub Desktop.
Save stackdump/08bf607e9eb29327988e to your computer and use it in GitHub Desktop.
bash script to max out cp load
#! /usr/bin/env bash
function cpuConsumingFunc {
echo 'worker started'
dd if=/dev/urandom | bzip2 -9 >> /dev/null;
}
function fulload {
x=0
while [ $x -lt $1 ]; do
cpuConsumingFunc &
let x=x+1
done
};
echo "----- Starting CPU load"
fulload $1;
echo "Press enter to stop CPU load"
read;
echo "----- CPU load stopped"
killall dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment