Skip to content

Instantly share code, notes, and snippets.

@vagelim
Created December 1, 2015 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vagelim/882b68100c87e7b205ea to your computer and use it in GitHub Desktop.
Save vagelim/882b68100c87e7b205ea to your computer and use it in GitHub Desktop.
CPU stress test
#!/bin/bash
# Usage: lc [number_of_cpus_to_load [number_of_seconds] ]
lc() {
(
pids=""
cpus=${1:-1}
seconds=${2:-60}
echo loading $cpus CPUs for $seconds seconds
trap 'for p in $pids; do kill $p; done' 0
for ((i=0;i<cpus;i++)); do while : ; do : ; done & pids="$pids $!"; done
sleep $seconds
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment