This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
开发者_如何学Go Improve this questionI was trying to find a UNIX/Linux command to limit memory and CPU usage once I realize that a process is consuming 90% or more. So basically a command to reduce usage on a process that is already running without restarting the process. Thank you.
nice (built-in) or cpulimit http://cpulimit.sourceforge.net/
/usr/bin/ulimit or the shell builtin ulimit can be used when you launch the process to set resource limits. Not after the process is running. The nice command is run as the process owner BEFORE you run the image file. Not after
renice is the command used after the process has already started.
I don't know how to set a hard limit on CPU usage. But you can force a process to be nicer to other processes with the renice
command
renice -n 10 -p PID
where PID
is the process id of the process whose priority you want to reduce.
What this does is tell the OS scheduler to reduce the process's priority, i.e. other processes that want to run get more of the CPU. man 1 renice
has the details.
精彩评论