如何创建一个bash命令CPU秒杀 [英] How to create a CPU spike with a bash command

查看:193
本文介绍了如何创建一个bash命令CPU秒杀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Linux机器上创建一个接近100%的负载。它的四核系统,我想会全速所有核心。理想情况下,CPU负载将持续指定的时间量,然后停止。我希望有一个在bash的一些诀窍。我想某种无限循环。

I want to create a near 100% load on a Linux machine. It's quad core system and I want all cores going full speed. Ideally, the CPU load would last a designated amount of time and then stop. I'm hoping there's some trick in bash. I'm thinking some sort of infinite loop.

推荐答案

您也可以做

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

要运行更多的那些穿上更多内核的负载,尽量叉吧:

To run more of those to put load on more cores, try to fork it:

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

在大括号重复命令多次要生成(此处4个线程)的线程数。
简单的输入命中将停止它(只需确保没有其他的DD是在该用户运行,或者你杀它太)。

Repeat the command in the curly brackets as many times as the number of threads you want to produce (here 4 threads). Simple enter hit will stop it (just make sure no other dd is running on this user or you kill it too).

这篇关于如何创建一个bash命令CPU秒杀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆