Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to simply simulate system load on Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to simply simulate system load on Linux". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to simply simulate system load on Linux".

CPU

The following command creates a CPU load by compressing random data and sending the results to / dev/null:

Cat / dev/urandom | gzip-9 > / dev/null

If you want more load, or if the system has multiple cores, all you need to do is compress and decompress the data, like this:

Cat / dev/urandom | gzip-9 | gzip-d | gzip-9 | gzip-d > / dev/null

Press CTRL+C to terminate the process.

Memory footprint

The following command reduces the total amount of memory available. It is achieved by creating a file system in memory and writing files to it. You can use as much memory as you want, just write more files into it.

First, create a mount point, and then mount the ramfs file system:

Mkdir zmount-t ramfs ramfs z /

The second step is to create a file in this directory using dd. Here we create a 128m file:

Dd if=/dev/zero of=z/file bs=1M count=128

The size of the file can be modified by the following operators:

Bs= block size. It can be any number followed by B (for bytes), K (for KB), M (for MB), or G (for GB).

How many blocks does count= have to write?

Disk IPUBO

The way to create disk I _ par O is to create a file first, and then use the for loop to keep copying it.

The following uses the command dd to create a 1G file with all zeros:

Dd if=/dev/zero of=loadfile bs=1M count=1024

The following command performs 10 operations with a for loop. Loadfile is copied each time to overwrite loadfile1:

For i in {1... 10}; do cp loadfile loadfile1; done

Adjust the run time by modifying the second parameter in {1... 10}. (LCTT translation note: the default cp command used on your Linux system is likely to be an alias for cp-I, in which case overriding will prompt you to enter y to confirm, you can use the cp command with the-f argument to override this behavior, or directly with the / bin/cp command. )

If you want to keep running until you press CTRL+C to stop, run the following command:

While true; do cp loadfile loadfile1; done thank you for reading, the above is the content of "how to simply simulate system load on Linux". After the study of this article, I believe you have a deeper understanding of how to simply simulate system load on Linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report