CPU usage restrictions for users?

I was wondering if there was a way to set resource usage per user. For example, if I use "grep -f <file1> <file2>" and the two files are very big it consumes a lot of resources. Onetime someone pinged me and asked what the hell I was doing and to kill it. Is there any way an SA can restrict usage so that no one consumes too many resources ? Maybe to divide resources evenly upon those actively logged in?

what is output of uname -a
if linux, what distro?

We use various distros - Linux, AIX, Solaris, and HP-UX. Uname -a does not list the distro (for Linux). It just identifies it as Linux.

Hi MaindotC,

You may try using the nice, renice and taskset commands.

Need some more help? - Try Man pages and search engines.

And, also we're there to help you :slight_smile:

Br,
VB

For Solaris take a look at http://docs.oracle.com/cd/E19253-01/817-1592/resource/index.html

There is no genuine way of restricting processor resources on a per-user basis, just on a per-process basis. Per process you can use "nice"/"renice", but this is not limiting the resources in an absolute way either, just in relation to all the other processes.

If you are looking for a "of the 5 available processors this process is only entitled to use 1"-solution: such a thing doesn't exist, at least not in general. In AIX there is the bindprocessor command (look at the man page of this command and search for "processor affinity AIX" in your favourite search engine to find out more), which comes close to this, i don't know if other OSes have a similar mechanism.

nice manipulates a process' priority (to be precise: it manipulates the way the kernel assigns a priority to said process): lets assume we have only one processor and several processes competing for its use. The Unix kernel would let the first process have the the processor for some time, then stop it, assign the processor for the same time to the next process, etc., until all the processes had their turn, then start over with the first one again. As this happens in rapid succession it looks like all the processes run simultaneously, but in fact they do not.

With priority entering the picture not all the processes will be given equal time any more. A process with high priority will get the processor for a longer time then a process with lower priority, so that a high-priority-process seems to run faster than a low-priority process.

Still, as long as all the processes' CPU demands can be satisfied every process gets as much as it wants, regardless how much that is. Even the lowest priority process can get 99% CPU as long as no other process demands it.

You might want to read the man pages for nice and renice to learn more about "process scheduling" and "process priority" (use these as starting points for web research) in the Unix kernel.

For limitations on a per-user basis there is "ulimit", but this does not limit processor use, only file size and memory usage. You may want to read the man page for ulimit too to see what you can do with it. Notice there are "hard" and "soft" limits. Basically, hard limits are imposed by the root user and the user cannot change them. Soft limits are also imposed by the root user, but can be changed by the user himself until reaching the hard limit, which is the absolute upper limit the user (and his processes) can use. Usually there is a hard limit somewhat higher than the soft limit and the difference serves as contingency for especially demanding situations. Users should be able to do their usual work within the soft limits and if they can't these values need rework.

I hope this helps.

bakunin

bash man page excerpt:

But: this would not limit the share or percentage of resources a user process will get during execution, but stop it from execution once it reaches the limits.

You can implement some static (they do not change depending on how many people are logged in) resource limits (memory, processes, cpu time, file size, descriptors, etc) using:

*BSD - /etc/login.conf
AIX - /etc/security/limits
Linux with pam_limits module - /etc/security/limits.conf

Regards,
Alister