LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (http://www.linuxquestions.org/questions/linux-security-4/)
-   -   limit CPU consumption (http://www.linuxquestions.org/questions/linux-security-4/limit-cpu-consumption-344791/)

eantoranz 07-19-2005 07:15 PM

limit CPU consumption
 
How can I force a CPU consumption limit? Say per user.... or system-wide.... both if possible? ;)

demian 07-19-2005 08:24 PM

You can limit the cpu time a process or user can use and the process priorities but you cannot limit a user to only use, say 50% of the available cpu cycles.

An easy way to set user limits is through pam_limits.so. The drawback is, that these limits are enforced on a per session basis, not system wide. So if you limit the cpu time to n minutes for a particular user this limit will be enforced on the current login session. If the user logs in m times he has m*n minutes cpu time available. Of course, you can also limit the number of simultanous logins through pam_limits. See /etc/security/limits.conf and man limits.conf.

If you need something more sophisticated you might need to turn on process accounting and write a script to automatically take action once certain limits are reached.

eantoranz 07-19-2005 08:29 PM

mmmmmmmm.......... well.... I think it would be OK if I set the nice level to a reasonable value... say......... 19 ;). Could that be set by root so that users can't set it BELOW the value set by root?

demian 07-19-2005 08:32 PM

Quote:

Originally posted by eantoranz
Could that be set by root so that users can't set it BELOW the value set by root?
Yes.

man renice and see my last post.


All times are GMT -5. The time now is 12:20 AM.