Jump to content

Restricting the number of programs


pjoshi

Recommended Posts

Hi,

 

We have a server and several thin clients attached to this in our Office. The OS is RedHat Linux. Whenever n number of applications/programs are opened on each thin client the performance of the server degrades.

 

Is there any way to restrict the number of programs that can be opened by each client or any other way that I can increase the performance of the server. Pls help :(

Link to comment
Share on other sites

Plenty of ways to do it but it would entirely depend on your setup. One simple method would simply be to create a lockfile when an application starts and not to let another copy of said application start while the lockfile exists.

Link to comment
Share on other sites

Thanks thorpe for the suggestion. But it would be great if you could tell me how to create a lockfile as I'm very new to such concepts.

 

Lets take an example of creating a lockfile for restricting one instance of the following applications.

1) Open Office 3.0

2) Acrobat Reader 5.0

3) Mozilla Firefox

 

Please help  :(

Link to comment
Share on other sites

  • 2 weeks later...

Hi Steve,

 

I went through the How To posted on http://www.cyberciti.biz/tips/linux-limiting-user-process.html as suggested by you. As mentioned in the post I configured my /etc/security/limits.conf file.

 

There are around 70+ users connected on the server and there were around 2700+ processes opened. I added the line pjoshi hard nproc 5 to the limits.conf file (pjoshi is one of the username connected to the server). Thinking that it would allow pjoshi to open maximum 5 processes.

 

I saved and closed the file and then executed the command : (){ :|:& };: on the prompt. But, to my surprise this resulted in big havoc. All the users were processes were stopped and were disconnected from the server. And even as a administrator I was unable to connect to the server until I restarted it.

 

I want to know what went wrong? Why other users processes got affected when I had added the line to restrict only the processes of the user – pjoshi.

 

Also please guide me how can I achieve this? Please feel free to ask any more questions in case of doubts to solve my problem.

Link to comment
Share on other sites

Why did you run a fork bomb? Of course that killed your server, albeit it shouldn't have if you done the config on the previous page correct.

 

Try creating a few processes for the pjoshi user yourself and see how it goes.

 

I suggest you read every bit of that page. Here is one of the comments you might want to look at:

#######

@Robert Delahunt: While I am on Ubuntu 9.04, your suggestion was the only one that worked. For me setting hard and soft limits for users in /etc/security/limits/conf had no effect. I had to place ulimit -u NUM in /etc/profile for it to stick. Thanks!

##########

 

I suggest you contact the author of that blog post to ask them about their config.

 

-steve

Link to comment
Share on other sites

Steve,

 

I have gone through the page throughly and have also tried putting ulimit -u NUM in /etc/profile but nothing is working for me.

 

Let me explain this in detail.

 

On the server I modified the file /etc/security/limits/conf by inserting a line backup hard nproc 100 and also inserted the line ulimit -u 100 in /etc/profile file.

 

After modifying the files I restarted the server. Then I logged in as backup and was able to open more than 100 processes.

 

I don't know what's going wrong. pls help .....

 

Thanks,

Prasad

Link to comment
Share on other sites

Well it works perfectly for me on Centos5.

 

I done this:

1. As root:

vi /etc/security/limits.conf

#add the following line, where steve is the user:

steve hard nproc 3

#save and close the text editor.

 

2. su - steve

steve@volcano:~$ ps -eaf | grep steve | more

-bash: fork: Resource temporarily unavailable

 

Try replicating this.

 

 

##############

On debian / ubuntu, I done:

1. As root:

vi /etc/security/limits.conf

#add the following line, where steve is the user:

sburke hard nproc 5

#save and close the text editor.

 

2. ssh sburke@localhost

ps -eaf | grep sburke | ls /var/tmp | less

-bash: fork: Resource temporarily unavailable

 

I did not have anything else to do. I did not have to reboot the server. I did not have to edit any other files. In the case of debian, su - sburke was insufficient. I had to ssh sburke@server, and then the limits kicked in.

-steve

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.