问题描述
为了测试时,系统资源变得稀缺(主要是CPU,但我感兴趣的磁盘I / O也是如此),我想,将系统上的任意加载程序如何反应。
In order to test how a program reacts when system resources become scarce (mainly the CPU but I'm interested in disk I/O too), I'd like to put an arbitrary load on the system.
目前我在做这样的事情:
Currently I'm doing something like this:
#!/bin/bash
while true
do
echo "a" >> a.txt
md5 a.txt
done
我也可以开始MP3编码的音频文件,或什么的。
I could also start mp3-encoding audio files, or whatever.
什么是一个简单的小bash脚本,可用于模拟任意负载,最好配置使用参数(S)?
What would be an easy and small Bash script that could be used to simulate an arbitrary load, ideally configurable using parameter(s)?
推荐答案
如果您正在寻找唯一的CPU负载,你可以简单地执行空循环:
If you are looking for only CPU load, you may simply execute an empty loop:
while :; do : ; done
磁盘I / O,您可以使用文件复制OD磁盘转储的序列(请参阅DD命令)
for disk I/O you can use a sequence of file copy od disk dump (see "dd" command)
问候
这篇关于击:简单的方法来把一个可配置的负载的系统上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!