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?

1

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.