# Usage: lc ]Įcho loading $cpus CPUs for $seconds seconds This shell function works at least under bash and ksh. Replace 4 with the number of CPUs you'd like to load if different from 4.Īssuming you had no background job already running when you launched one of these loops, you can stop the load generation with that command: for i in 1 2 3 4 do kill %$i doneĪnswering comment, here is an enhanced version that simplify a lot stopping the load and that also allow specifying a timeout (default 60 seconds.) A Control- C will kill all the runaway loops too. not dash or older ksh), you can use this non portable syntax: for i in do. If you use bash, ksh93 and other shells supporting ranges, (i.e. Each loop is able to load a CPU core at 100%. Each of them is repeating the null instruction ( :). How it works is quite simple, it starts four endless loops. This one-liner will load your four cores 1 at 100%: for i in 1 2 3 4 do while : do : done & done No need to install any extra package, your good old shell is able to do it alone.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |