Limiting the resources of Ubuntu

May 2017



Limiting resources of specific processes under Ubuntu

On Ubuntu (and on most Linux distributions) you can easily prevent a program to consume all the power of the computer. Here's how:

Limit CPU usage


If an application uses the CPU at 100%, this could block everything. You can limit the process with the cpu limit command. Open a terminal and type:
cpulimit -e process -l 40

In this example this "process" will be limited to 40% maximum.
You can also use the process PID (which can determine top):

cpulimit -p 130 -l 40


There the process with PID 130 would be limited to 40%.
We simply open the program then set the limit.
It may be that you have to install cpulimit before. Refer to your distribution for that. The official website is http://cpulimit.sourceforge.net/.

Restrict disk access

  • If an application is using excessive disk drive, the system may crash, You can use the ionice command to solve this issue.
    • ionice -c3 PID 
  • This command reduces disk access priority of a process (defined by its PID).
  • We simply open the program then set the limit.
  • Again it must be installed if it is not. (official site?)

Limiting bandwidth


A good thing is to limit the bandwidth (upload and download).

With Tickle

  • The command to be used is trickle. Close program and then launch the command:
    • trickle -d 90 program
  • The program will be limited to 90Kbps for download. To limit upload, use the option "-u":
    • trickle -u 90 program
  • Here, the program is closed, and is limited from the start. To remove the limitation you must close and re-open it.
  • Again, you may need to install trickle if it is not set up by default.
  • http://monkey.org/~marius/pages/?page=trickle

With Wget (single file)


If you want to download just a single file, you can use the basic but powerful wget:

wget --limit-rate=90k http//www.site.org/file.ext

Related


Published by jak58. Latest update on August 14, 2010 at 07:08 AM by jak58.
This document, titled "Limiting the resources of Ubuntu," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).