0

We're multiple user to work on a same account

I want to limit my activities to not hang the computer, to not bother the other users. I want to limit my resources' usage to not use it all (because if a process can, it uses it all)

There are 2 approaches, the priority one and strict limit one. Problem is, Linux don't manage very well priorities, meaning you'll slow down other activities even with the worse priority. So it let the strict limit

But I want to limit only my shell, not the account that many person uses

Do you have suggestions regarding priorities or strict limit?

7
  • 1
    ulimit will set the resource limits of the current shell process. Is this not what you want?
    – Kusalananda
    Apr 15, 2022 at 8:32
  • From what I read, it set it for users, and you have to restart the shell, who miss the whole point
    – aac
    Apr 15, 2022 at 8:35
  • It is usually considered bad practice for multiple users to use one account. Is there any way that you can create an account for each user?You may need to consider group accesses and/or ACLs, but you'll have a much more robust system and one that can easily have limits applied.
    – user516667
    Apr 15, 2022 at 8:38
  • 1
    Then you will have to refer to that text in your question because that's not what it does. It sets the resource limits for the current process, i.e. the current shell. You don't have to restart the shell after giving the ulimit command in a shell session. Also, why are you working on the same account? Using the same machine is fine, but I see no reason to share accounts for any sort of work.
    – Kusalananda
    Apr 15, 2022 at 8:39
  • 1
    Um, if you're sharing one account, there are no "other users".
    – Kusalananda
    Apr 15, 2022 at 8:40

1 Answer 1

3

ulimit can be used for this: it sets the limits for the current shell, not for the user globally or for future shells; and these limits are inherited by processes started in that shell.

To convince yourself of that, open two shells with the same user on the same system; examine the limits (ulimit -a) in both, then in one of them, set limits using ulimit, and then run ulimit -a again in the other shell — the limits applied in the first shell won’t affect the second shell.

The limits set by ulimit, on Linux, are described in detail in the setrlimit man page. They aren’t really useful if you want to “play nice” with other users’ workloads on a shared system; they prevent runaway processes from contributing to resource exhaustion (e.g. one can prevent processes from creating huge files).

You might want to look into cgroups if they are available on your system, and accessible to you as a regular user. These give more control over memory, CPU and I/O usage, which is what typically creates problems on multi-user systems.

6
  • What cgroups can give me more ? Where can I learn extensively how to use each options of ulimit? The man doesn't explain the set limits, only the command refuses to operate if i'm out of bounds. What are the minimal parameters for each flags? (not to use as is but to know the bounds)
    – aac
    Apr 15, 2022 at 8:55
  • How to modify scheduling priority, pipe size, real-time priority ? It doesn't seem to work. Does cgroups permit modification on a shell only and on real time without reloading anything?
    – aac
    Apr 15, 2022 at 9:46
  • ulimit sets limits; it doesn’t change priorities. As indicated in the documentation, you can’t change the pipe size, you can only view it. cgroups sets limits on process trees, without reloading anything (you can create a cgroup and move processes into it). Apr 15, 2022 at 10:19
  • So I can only view scheduling priority and real-time priority?
    – aac
    Apr 15, 2022 at 11:02
  • You can set the limits on priorities. You need other tools to set priorities (nice, chrt). Apr 15, 2022 at 11:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .