Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何自动运行ulimit-c unlimited_C_Linux_Coredump_Ulimit_Rootfs - Fatal编程技术网

如何自动运行ulimit-c unlimited

如何自动运行ulimit-c unlimited,c,linux,coredump,ulimit,rootfs,C,Linux,Coredump,Ulimit,Rootfs,我试图从我的rootfs提供对coredump文件生成的支持,我使用“ulimit-c unlimited”命令和“*hard core-1”修改了/etc/limits文件,现在我给kill-6$$,希望生成核心文件,但要得到这个核心文件,必须显式运行ulimit-c unlimited 但我希望它自动发生,不需要在shell中再次运行ulimit-c unlimited 有人能告诉我,为了使相同的情况发生,我必须对程序进行哪些更改吗?您可以使用setrlimit(RLIMIT_CORE,…)

我试图从我的rootfs提供对coredump文件生成的支持,我使用“ulimit-c unlimited”命令和“*hard core-1”修改了/etc/limits文件,现在我给kill-6$$,希望生成核心文件,但要得到这个核心文件,必须显式运行ulimit-c unlimited

但我希望它自动发生,不需要在shell中再次运行ulimit-c unlimited


有人能告诉我,为了使相同的情况发生,我必须对程序进行哪些更改吗?您可以使用
setrlimit(RLIMIT_CORE,…)
设置核心文件的最大大小。指定无限大小的过程
RLIM_INFINITY

有关详细信息,请阅读此处:


使用
sysctl
命令可以执行以下操作

sysctl kernel.core_pattern=/var/core/core.%p
让内核在
/var/core
中创建名为
core.
的内核

kernel.core\u模式=/var/core/core.%p
添加到
/etc/sysctl.conf
将使其永久化。(运行
sysctl-p
处理对
/etc/sysctl.conf
的更改)

除了
%p
(进程id)之外,还有其他占位符,如下所示():


把它放在你的
.profile
文件中?把这一行添加到你的shell启动文件中,可能是
~/.profile
。你可能想继续读下去。看起来您可以使用一些有关如何设置您自己的配置文件的信息。由于某些原因,无法将其放入配置文件中,如果我更改为配置文件,这将仅对从登录shell启动的程序生效,而不会对systemd启动的进程/服务生效/etc/限制将是这些默认设置的正确位置told@Nobilis您想对上述内容发表评论吗?谢谢@alk,我正在寻找类似的内容,因此我需要在my/etc/sysctl.conf中指定sysctl kernel.core\u pattern=/var/cor/core.%p??那么我真的需要显式运行ulimit-c unlimited吗???@amitsightomar:
内核。core_模式
指定放置核心文件的位置以及如何命名。很好@alk但它不能解决我的问题,Cav我们在/etc/limits文件中设置核心文件的最大大小?@amitsightomar:您可能想使用
setrlimit()
根据我的回答,从您的程序之外到她,核心文件的最大大小。是@alk,这就是我正在研究的内容。您知道在Linux代码中它是在哪里设置的吗。
%%  a single % character
%p  PID of dumped process
%u  (numeric) real UID of dumped process
%g  (numeric) real GID of dumped process
%s  number of signal causing dump
%t  time  of dump, expressed as seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)
%h  hostname (same as nodename returned by uname(2))
%e  executable filename (without path prefix)
%E  pathname of executable, with slashes ('/') replaced by exclamation marks ('!').
%c  core  file  size soft resource limit of crashing process (since Linux 2.6.24)