Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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:
@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.
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.
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.