Limiting cpu usage per process

nitin bansal linuxwatch at gmail.com
Wed Mar 2 05:50:17 UTC 2005


HI thr,

Ulimit provides control over the resources available to processes
    started by the shell, on systems that allow such control.  If an
    option is given, it is interpreted as follows:

        -S      use the `soft' resource limit
        -H      use the `hard' resource limit
        -a      all current limits are reported
        -c      the maximum size of core files created
        -d      the maximum size of a process's data segment
        -f      the maximum size of files created by the shell
        -l      the maximum size a process may lock into memory
        -m      the maximum resident set size
        -n      the maximum number of open file descriptors
        -p      the pipe buffer size
        -s      the maximum stack size
        -t      the maximum amount of cpu time in seconds
        -u      the maximum number of user processes
        -v      the size of virtual memory

    If LIMIT is given, it is the new value of the specified resource.
    Otherwise, the current value of the specified resource is printed.
    If no option is given, then -f is assumed.  Values are in 1024-byte
    increments, except for -t, which is in seconds, -p, which is in
    increments of 512 bytes, and -u, which is an unscaled number of
    processes.
To disallow core files (by setting the maximum size to 0) for example you
would add:

ulimit -Hc 0
To set limits globally you would need to edit "/etc/profile", of course this
will also affect root, so be careful! To set limits on groups you would need
to add scripting to "/etc/profile" that would check for the user's
membership in a group and then apply the statements, however doing this with
PAM is recommended as it is a lot simpler.

To set a soft limit on the maximum amount of memory available to a
given process to a value that is less than the total amount of memory
on the system on a system with 1 gig of real memory and 500 megs of
virtual memory you would set the following values in /etc/profile:

ulimit -S -m 1000000
ulimit -S -v  500000
 

With this value set, the system will kill any process that tries to
take up more resources than you have set as a limit

also give a look to d following link--

http://www.crucialparadigm.com/resources/tutorials/server-administration/how-to-howto-install-prm-process-resource-monitor.php

Nick.


On Tue, 1 Mar 2005 08:35:18 -0600, McDougall, Marshall (FSH)
<MarMcDouga at gov.mb.ca> wrote:
> I have a situation where I occasionally encounter a runaway vim process.  It
> eats up all available cpu.  I am looking for a way to limit the usage of
> said process.  I have seen Google results that allude to resource.h, but I
> have yet to find a comprehensive method of accomplishing this task.  Any
> help appreciated.  Thanks.
> 
> Regards, Marshall
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
>




More information about the redhat-list mailing list