限制 Linux 中用户可用的内存和 CPU

发布于 2024-07-12 08:43:16 字数 90 浏览 6 评论 0原文

我有点关心共享计算机中可以使用的资源量。 有什么方法可以测试管理员是否对我可以使用的资源量有限制? 如果是的话,为了提出一个更完整的问题,我该如何设置这样的限制?

I am a little concerned with the amount of resources that I can use in a shared machine. Is there any way to test if the administrator has a limit in the amount of resources that I can use? And if does, to make a more complete question, how can I set up such limit?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浸婚纱 2024-07-19 08:43:16

对于与进程相关的限制,您可以查看 /etc/security/limits.conf (阅读文件中的注释,使用 google 或使用 man limits.conf更多信息)。 正如 jpalecek 指出的那样,您可以使用 ulimit -a 来查看(并可能修改)当前有效的所有此类限制。

您可以使用命令 quota 查看磁盘配额是否有效。

For process related limits, you can have a look in /etc/security/limits.conf (read the comments in the file, use google or use man limits.conf for more information). And as jpalecek points out, you may use ulimit -a to see (and possibly modify) all such limits currently in effect.

You can use the command quota to see if a disk quota is in effect.

吖咩 2024-07-19 08:43:16

您可以尝试运行

ulimit -a

以查看哪些资源限制有效。 另外,如果允许您更改此类限制,则可以通过 ulimit 命令更改它们,例如。

ulimit -c unlimited

解除进程可以创建的核心文件大小的任何限制。

You can try running

ulimit -a

to see what resource limits are in effect. Also, if you are allowed to change such limits, you can change them by the ulimit command, eg.

ulimit -c unlimited

lifts any limit for a size of a core file a process can make.

海风掠过北极光 2024-07-19 08:43:16

在C层面,相关函数(实际上是syscalls(2)...) 可能是 setrlimit(2)setpriority(2)sched_setattr(2)。 您可能希望从您的 shell 中调用它们。

另请参阅 proc(5) - 并尝试 cat /proc/self/limitssched(7)

您可能需要使用 renice(1) 命令。

如果您运行一个持久的程序(几个小时)不需要用户交互,您可以考虑使用一些批处理处理。 某些 Linux 系统有 batchat< /代码>命令

At the C level, the relevant functions (actually syscalls(2)...) could be setrlimit(2) and setpriority(2) and sched_setattr(2). You probably would want them to be called from your shell.

See also proc(5) -and try cat /proc/self/limits and sched(7).

You may want to use the renice(1) command.

If you run a long-lasting program (for several hours) not requiring user interaction, you could consider using some batch processing. Some Linux systems have a batch or at command.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文