0

If a process is run by multiple users, how can we set threshold (maximum) number of process has reached in Linux?

I have to set a warning when that threshold is reached. The processes can be run by multiple users. How can I calculate and set a value for this in Linux?

tshepang
  • 12,111
  • 21
  • 91
  • 136
  • Do you mean one particular program, which is run by multiple users? There is difference between process and program, see http://stackoverflow.com/questions/12999850/what-are-differentiates-between-a-program-an-executable-and-a-process – Joe Kul Jul 01 '13 at 14:07

1 Answers1

0

I'll answer the question that I think you are asking.

One program can have multiple instances running. Each is a separate process. I'm not aware of any instance count that Linux makes available. So I don't think there is any setting that can be made to get Linux to enforce a maximum number of instances for you.

If user access to the program can be forced to come through a shell script or wrapper program, you have some options.

1) To just give a warning to users invoking the program who have reached or exceeded the number of instances, you could do a shell script that does something like

ps aux | grep TheProgramFileName > $InstanceCount

Then the script would compare to a maximum, and warn the user. But that won't stop anyone.

2) If the goal is to prevent multiple instances, that can be done by a shell script. Refer to single instance and preventing multiple instances.

3) For maximum N instances, see cooperative limiting. But I don't think this can be done in a shell script.

Community
  • 1
  • 1
Joe Kul
  • 2,454
  • 16
  • 16