max*_*imb 14 command-line bash ulimit
我的问题可能与 Ubuntu 无关,但由于我的桌面运行此操作系统,因此我来到了此论坛。
我正在尝试使用以下ulimit -c命令更改核心文件大小:
$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7959
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
Run Code Online (Sandbox Code Playgroud)
更改限制:
$ ulimit -c unlimited
Run Code Online (Sandbox Code Playgroud)
观察结果:
$ ulimit -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7959
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
Run Code Online (Sandbox Code Playgroud)
确实是改变了限制。但是,当我打开另一个终端并检查该值时,我仍然看到核心文件大小为零值。
问题:
ulimit命令所做的更改是否仅影响当前进程,即在这种情况下bash?ulimit变更是否适用于新流程?mur*_*uru 12
ulimit 是一个内置的 shell,因此只影响当前的 shell 和由该 shell 启动的进程:
$ type ulimit
ulimit is a shell builtin
Run Code Online (Sandbox Code Playgroud)
来自man ulimit:
The ulimit utility shall set or report the file-size writing limit
imposed on files written by the shell and its child processes (files of
any size may be read). Only a process with appropriate privileges can
increase the limit.
Run Code Online (Sandbox Code Playgroud)
所以,是的,子进程受到影响。
要永久设置限制或为所有进程设置限制,请编辑/etc/security/limits.conf并重新启动。联机帮助页中的示例相当不错。您只需要添加如下内容:
username - core unlimited
Run Code Online (Sandbox Code Playgroud)