Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I explicitly allocate resources (from both cpu and physical memory) to a particular side e.g. Network or to a Process.

Thank You

share|improve this question
up vote 2 down vote accepted

Generally speaking, processes will take as much of both CPU and network bandwidth as they can, relative to the rest of the system. You can't, to my knowledge, explicitly give one process a certain amount of CPU speed like you can with virtual machines.

What you can do is adjust the scheduling priority of the process using "nice", though, as Crankyadmin mentioned. According to the "nice" scale, programs run from 19 (the least priority) to -20, the highest priority, and programs typically run at 0.

Notice that non-root users can only, by default, adjust their programs in the 19-0 range. Only the superuser can schedule priorities below 0 (adjust this default using ulimit in /etc/profile, but ONLY do it if you know what you're doing).

To run a new process at a specific nice level, do

$ nice -n 10 pwd

This runs the command at a nice level of 10. The $ indicates that it's a regular user. Here's what happens when you try to set a higher nice level:

$ nice -n -20 pwd
nice: cannot set niceness: Permission denied

Now, as root, we succeed

## nice -n -10 pwd

To change the nice level of an already-running process, use "renice". So if I wanted my firefox session to go faster (dumb idea), I would do this:

renice -10 <firefox-PID>

Be careful doing this. Every time a process spawns a child process, that child process inherits the parent process's nice level. This means that if firefox (in my case) goes berserk, the system will probably go with it. That's why the maximum priority a user can change to is 0.

Be careful.

share|improve this answer

ulimits and nice :D

share|improve this answer
Please be more specific – Muahmmad Zeeshan Nov 17 '09 at 14:05
@Muahmmad - Look them up. If you read the FAQ, you'll find that this site is for professional system administrators, and that general questions like this belong on SuperUser. Here you are expected to have a certain amount of resourcefulness in figuring things out. Check a Unix or Linux manual or the man pages. – David Thornley Nov 17 '09 at 14:30
@David +1 You read my mind! – Crankyadmin Nov 17 '09 at 14:31
With all due respect to my esteemed co-serverfaulties, the goal of this community is, in my view, to function as a resource. To repeatedly point people asking questions does a disservice to them, in discouraging them from asking further questions, and to people visiting this thread in the future, because you have essentially contributed nothing of value except pointers to other resources (at best), which may or may not exist in 6 months or a year. Instead of answering with three words, take the time to explain and create something of value for now and the future. – Matt Simmons Nov 17 '09 at 14:47
Have to agree with Matt on this one. Either you should point the guy to a thread where this has already been answered, or you should give a better answer. Nothing I hate more than googling, and finding a thread where everyone clearly knows the answer, but isn't willing to tell the person asking the question because they feel he lacks moral fortitude or some such crap. If you don't think he deserves to know, just stfu...Giving a half-assed answer is just a way to show off. – Satanicpuppy Nov 17 '09 at 14:57

cpusets are a relatively new Linux feature, I haven't played with it yet, but it sounds interesting. Here's some linkage:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.