Limiting total CPU usage in Linux
Forum rules
This General Discussion board is meant for topics that are still relevant to Pale Moon, web browsers, browser tech, UXP applications, and related, but don't have a more fitting board available.
Please stick to the relevance of this forum here, which focuses on everything around the Pale Moon project and its user community. "Random" subjects don't belong here, and should be posted in the Off-Topic board.
This General Discussion board is meant for topics that are still relevant to Pale Moon, web browsers, browser tech, UXP applications, and related, but don't have a more fitting board available.
Please stick to the relevance of this forum here, which focuses on everything around the Pale Moon project and its user community. "Random" subjects don't belong here, and should be posted in the Off-Topic board.
Limiting total CPU usage in Linux
Having received fresh insight in a recent discussion here, I think I should ask a question to address a minor problem which has been with me for years. As the title states, I would like to restrict the share of my computer’s processor capacity in use at any one time. This had been possible in Windows 7 through the Power Options, but I cannot find any information on how to do this in Linux. LimitCPU comes up in most relevant online discussions, but applies to individual processes, whereas I am looking for a cap on total resources used to 50% of the CPU’s capacity. A random thread from 2008 mentions ulimit, but none of its options seem to apply to CPU usage directly. Should it apply, my computer has four cores, and I would like this limit to apply to all four cores, so it cannot run two cores fully and leave the others idle to achieve this. I would like this always to run within my userspace. How can I achieve this?
Browser: Pale Moon (official build, updated regularly)
Operating System: Linux Mint Debian Edition 4 (amd64)
※Receiving Debian 10 ELTS security upgrades
Hardware: HP Pavilion DV6-7010 (1400 MHz, 6 GB)
Ash is the best letter.
Operating System: Linux Mint Debian Edition 4 (amd64)
※Receiving Debian 10 ELTS security upgrades
Hardware: HP Pavilion DV6-7010 (1400 MHz, 6 GB)
Ash is the best letter.
- andyprough
- Board Warrior
- Posts: 1031
- Joined: 2020-05-31, 04:33
Re: Limiting total CPU usage in Linux
This does not sound like a good idea to never allow more than 50% usage. I think what you are looking for is going to be best served by searching online and reading about "linux cpufreq powersave".
Edit: Although - a little searching led me to this interesting discussion about using cpu.shares in cgroups to accomplish what you are looking for: https://unix.stackexchange.com/a/151892
This part of the discussion sounds like what you are describing: "we use cgroups to limit the maximum number of cores an entire login session can use".
systemd manages cgroups and your Linux Mint distro uses systemd, so if you have the time to do some research I think this could be useful.
- Bottennapp
- Newbie
- Posts: 3
- Joined: 2025-02-21, 19:20
Re: Limiting total CPU usage in Linux
Could this be of any help?
IIRC there is a command in linux/unix which hinders a program from hogging overly much of the resources.
If one gives the command nice program (like nice firefox or nice process number) that program should not force total priority of resources.
googlegooglegoogle It seems there are nice and renice, where nice sets a value to a process, and renice resets it to another value. You can give specific value to the niceness of the process.
If this looks interesting, I suggest you google for it. There are lots more to it than I have said.
cheers!
IIRC there is a command in linux/unix which hinders a program from hogging overly much of the resources.
If one gives the command nice program (like nice firefox or nice process number) that program should not force total priority of resources.
googlegooglegoogle It seems there are nice and renice, where nice sets a value to a process, and renice resets it to another value. You can give specific value to the niceness of the process.
If this looks interesting, I suggest you google for it. There are lots more to it than I have said.
cheers!
- Bottennapp
- Newbie
- Posts: 3
- Joined: 2025-02-21, 19:20
Re: Limiting total CPU usage in Linux
Yes, you can give a cap on a group of resources in diverse ways. (Says he who clicks Enter first, and thinks afterwards...) cheers!