gpt4 book ai didi

linux - 如何使 "find"命令变慢

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:44:04 24 4
gpt4 key购买 nike

您没看错:我想让 Linux 的“查找”命令变慢,并使用更少的系统资源。我创建了一个 cronjob,它每 10 分钟运行一次 find 命令,但是当它运行时,find 命令几乎占用了我所有的 CPU 大约 3 分钟,几乎没有给我的 SO 留下任何东西。

所以我希望能够让“查找”命令运行得慢一点,这样它就不会使用我的 Centos 服务器的太多资源,并在 10 分钟内稳定运行,而不是使用所有资源 3 分钟。

这可能吗?

最佳答案

根据 this :

The nice command tweaks the priority level of a process so that it runs less frequently. This is useful when you need to run a CPU intensive task as a background or batch job. The niceness level ranges from -20 (most favorable scheduling) to 19 (least favorable). Processes on Linux are started with a niceness of 0 by default. The nice command (without any additional parameters) will start a process with a niceness of 10. At that level the scheduler will see it as a lower priority task and give it less CPU resources.

所以你可以简单地将你的任务包装在一个 nice 中,这将改变任务的优先级。

改变

whatever

nice whatever

关于linux - 如何使 "find"命令变慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34522054/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com