简体   繁体   中英

CPU stress testing by percentage with native linux command

I am currently running the following commands to stress test my CPU:

md5sum /dev/zero

Then I kill the process after 30 seconds.

pkill md5sum

I am looking to run a similar command but where it lets me stress the CPU by a certain percentage. I cannot use libraries like stress-ng, it has to be be able to run with basic linux distro like ubuntu. I also can't run a program as such, I have to be able to run it from the command line itself. Any suggestions or help is greatly appreciated.

I don't believe this is possible without installing a tool (like cpulimit , available in Ubuntu apt repo) or by using cgroups , which is complex to configure and potentially requires kernel rebuilding.

The nearest standard feature is nice , which essentially sets the process priority. So without anything else running, it would still use all the CPU time, but any other processes would get CPU priority.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM