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 use cpulimit in Linux to restrict cpu usage of processes

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article introduces the knowledge about "how to use cpulimit to limit the cpu usage of the process in Linux". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

When using Linux, you may often find that it becomes very slow inexplicably, and most of the background processes use too much CPU and memory. How do you limit cpu usage per process?

You can use cpulimit to limit cpu usage per process, which is expressed as 100 percent.

Install cpulimit

Install using source code

# cd /tmp

# wget 'http://downloads.sourceforge.net/cpulimit/cpulimit-1.1.tar.gz'

# tar cpulimit-1.1.tar.gz

# cd cpulimit-1.1

# make

# cp cpulimit /usr/local/sbin/

# rm -rf cpulimit*

Debian / Ubuntu users

Use apt-get for easier installation

$ sudo apt

-

get update

$ sudo apt

-

get install cpulimit

How to use cpulimit?

Limit firefox to 30% cpu utilization

# cpulimit -e firefox -l 30

Limit process number 1313 to 30% CPU utilization

# cpulimit -p 1313 -l 30

How to find pid based on process name

# ps aux | less

# ps aux | grep firefox

# pgrep -u vivek php-cgi

# pgrep lighttpd

Absolute paths can be used to limit cpu utilization of processes

# cpulimit -P /opt/firefox/firebox -l 30

Single core CPU and multicore CPU

the utilization rate of a single-core cpu ranges from 0% to 100%, and the utilization rate of a quad-core cpu ranges from 0% to 400%.

related tools

nice: Runs the program at the specified priority

renice: Adjust the priority of the process to run

"Linux how to use cpulimit process cpu usage" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

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: 254

*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