/ linux

Generate CPU load and stress

To generate load or CPU spikes on Linux machines the stress utility and even dd can be used.

# install stress
$ sudo apt-get install stress -y
# generate cpu spikes
$ stress --cpu 2 --timeout 60

A way for more IO in contrast to CPU the dd utility might be useful like:

$ dd if=/dev/zero of=/dev/null

A short helper script:

$ fulload() { dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null & }; 
$ fulload; read; killall dd

When hitting enter all dd's will be stopped.