LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   ulimit in linux (https://www.linuxquestions.org/questions/linux-server-73/ulimit-in-linux-472607/)

ahpin 08-10-2006 06:12 AM

ulimit in linux
 
Hi,

I would like to know if we can use ulimit to control the maximum memory usage per process and cpu for each all the normal user on the linux system? The reason behind is i want to control the max usage of memory per user, in order to avoid the system memory and cpu highload, which will causing system hung.

Any advice will be appreciated.

Thanks

Samoth 08-10-2006 06:49 AM

I thought ulimit controlled the amount of disk space a certain user could use? maybe it does more.....

kordump 08-10-2006 01:28 PM

I don't think there is a way to limit cpu usage as a percentage, but you can limit the amount of CPU time a user process is allowed as well as the maximum memory resident size. Instead of controlling these settings with ulimit, this is better configured by configuring /etc/security/limits.conf - especially if you want to control more than 1 user. To answer your question's specifics, here is an example of a limits.conf file trying to accomplish your goals:
Code:

@foo            hard    cpu            10
@foo            hard    rss            10240

This would limit each user (who is a member of the group 'foo') process to 10 minutes of CPU time - at which point the process would be killed. It should also limit the amount of memory a process can use to 10MB. You'll want to read the documentation that resides in the limits.conf file and make adjustments accordingly. I hope this points you in the right direction.

ahpin 08-10-2006 08:28 PM

Thanks a lot for all the feedback. I'm thinking if control the limit, there will be the risk that it will kill the user job which reall need so much memory. Or may be i should ask if there is a way to reserve the memory and cpu resources for system process, instead of controlling at the user level.

kordump 08-11-2006 12:52 PM

Generally, the system processes will always have a higher priority than user processes. So when the system is 'hanging' it is the users' processes that are hanging and not the system processes that are hanging. It appears to me that you just have an overloaded system and should look into taking other action, such as:
1) Moving some users to a different server.
2) Upgrading to a server (or servers) with more and faster CPUs as well as more RAM.
I think you certainly have enough justification to take either action.

ahpin 08-11-2006 09:04 PM

Thanks for adviced....ya, there is a lot of user session on the system. I already have 4GB memory on the system. And most of the user just running normal Xvnc and ssh session.

Thanks man.


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