nice -n 19 find . -type f \( -iname "*.php" -o -iname "*.js" -o -iname "*.inc" \) \
-exec zip live.zip '{}' \;
The above command runs on our live CentOS server as though the nice
command was absent. After 60 seconds or so I can see that zip
is on 'top' when using the top
command. The server starts to fall over and I have to crash the command.
nice
only sets a process' scheduling priority. It does not limit how much CPU time it consumes.So: If a low priority process wants to consume a lot of CPU time/resources, then it will get them. Until a process with higher priority comes along to hog CPU time.
The point being: If the CPU doesn't have anything else to do, then why not provide all CPU time to the process that wants it, even if it doesn't have high priority?
If you want to limit CPU usage to a % of the maximum, then consider using something like
cpulimit
EDIT:
Other reasons why
zip
might be slowing things down horribly are:Disk I/O: Which you can control with
ionice
on some distros (not sure if CentOS has it by default) - David Schmitt pointed this out in a comment below.zip
might allocate a lot of memory, and swap out other processes. Then when these processes wake up (saymysqld
gets a query), they are sluggish. You might be able to do something about this by reducing Swappiness. But that is a system level parameter and you probably want to leave it untouched.