• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

CPUTool – Limit and Control CPU Utilization of Any Process in Linux

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
140
VIEWS
Share on FacebookShare on Twitter

Contents

  1. How Does CPUTool Work?
  2. Install CPUTool to Limit CPU Usage and Load Average
    1. Limiting Process CPU Usage With CUPTool
    2. Limiting System Load with CUPTool

One of the critical areas under Linux performance monitoring has to be CPU usage and system load. There are several Linux performance monitoring tools to keep an eye on how things are unfolding on a system.

A number of these tools simply output the system state/statistics while a few others provide you means of managing system performance. One such tool called CPUTool.

CPUTool is a simple yet powerful command-line tool for limiting and controlling CPU utilization of any process to a given limit and allows the interruption of process execution if the system load overreach a defined threshold.

How Does CPUTool Work?

In order to limit CPU usage, cputool sends the SIGSTOP and SIGCONT signals to processes and this is determined by the system load. It relies on the /proc pseudo-filesystem to read PIDs and their CPU usage measures.

It may be used to limit the CPU usage or system load influenced by a single process or a group of processes to a given limit and/or suspend processes if the system load goes beyond a threshold.

Suggested Read: Understand Linux Load Averages and Monitor Performance of Linux

Install CPUTool to Limit CPU Usage and Load Average

A CPUTool is only available to install on Debian/Ubuntu and its derivatives from the default system repositories using package management tool.

$ sudo apt install cputool

Limiting Process CPU Usage With CUPTool

Now lets look at how cputool really works. To demonstrate it all, we will run a dd command which should result into a high CPU percentage, in the background and display its PID.

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

To monitor CPU usage we can use the top or glances tools that allow us to view a real-time regularly updated state of a running Linux system processes:

# top
CPUTool – Limit and Control CPU Utilization of Any Process in Linux

Monitor dd Command CPU Usage

From the output above, we can see that dd command is having the highest percentage of CPU time 99.7%) Now we can limit this using cputool as shown below.

The --cpu-limit or -c flag is used to set a usage percentage for a process or group of processes and -p to specify a PID. The following command will limit the dd command (PID 8275) to 50% use of one CPU core:

# cputool --cpu-limit 50 -p 8275 

After running cputool, we can check the new CPU usage for the process (PID 8275) once more. Now the CPU usage for dd process should range from (49.0%-52.0%).

# top
CPUTool – Limit and Control CPU Utilization of Any Process in Linux

Limit Process CPU to 50% Usage

To further limit dd’s CPU usage to 20%, we can run cputool for a second time:

# cputool --cpu-limit 20 -p 8275 

Then immediately check using tools such as top or glances like this (the CPU usage for dd should now range from 19.0%-22.0% or slightly beyond this):

# top
CPUTool – Limit and Control CPU Utilization of Any Process in Linux

Limit Process CPU Usage to 20%

Note that the shell doesn’t expect any user input while cputool is running; therefore becomes unresponsive. To kill it (this will terminate the CPU usage limitation operation), press Ctrl + C.

Importantly, to specify a process group (one program with several running instances each with a distinct PID) for instance HTTP web server:

# pidof apache2
9592 3643 3642 3641 3640 3638 3637 1780

Use the -P flag like this:

# cputool --cpu-limit 20 -P 1780

Limiting System Load with CUPTool

The -l option is used to specify the maximum load the system may go though for the process or process group to continue running. We may use a fractional value (e.g. 2.5).

The example below means run rsync for a local backup only when the system load does not exceed 3.5:

# cputool --load-limit 3.5 --rsync -av /home/tecmint /backup/`date +%Y-%m-%d`/

For more information and usage, view the CPUTool man page:

# man cputool

Do check out following useful guides for finding CPU info and CPU performance monitoring:

  1. 9 Useful Commands to Get CPU Information on Linux
  2. Cpustat – Monitors CPU Utilization by Running Processes in Linux
  3. CoreFreq – A Powerful CPU Monitoring Tool for Linux Systems
  4. Find Top Running Processes by Highest Memory and CPU Usage in Linux

In conclusion, CPUTool really comes in handy for Linux performance management. Do share your thoughts about this article via the feedback form below.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

Display Command Output or File Contents in Column Format

Next Post

Linux Fun – How to Create ASCII Text Banners in Terminal

Next Post

Linux Fun – How to Create ASCII Text Banners in Terminal

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet