Quote:
Originally posted by win32sux
i think you misunderstood the question... vanv101's asking how to limit the cpu usage of certain processes - not how to see their current usage...
|
Sorry!
As far as I am aware, there's still no absolute way to limit the CPU usage of a given process in Linux. You could start looking at soft real-time scheduling, which would give the process a fixed amount of your CPU time, but that's probably overkill.
Instead, Linux provides a less aggressive mechanism called the
nice value. The schedular allocates a priority to each process by a number of factors — how much the process volentarily sleeps, how much of the CPU it's been using in the past few milliseconds, and so on. One of the factors is called the niceness value.
The niceness value acts to increase or reduce the priority of a given process, after everything else has been calculated. Niceness ranges from -20 to +19; the default value is 0, higher values lower the priority and lower values increase it.
The amount of CPU time given to each process depends on its priority relative to other processes in the system (except that a process can deliberately sleep before its slice of the CPU is up, giving way to the next process).
So if you increase its niceness value, this decreases its priority and makes the process take less CPU time.
Code:
/sbin/renice +20 pids
You need to be the owner of a process (or root) to increase its niceness, and you need to be root to decrease it.