English 中文(简体)
如何为centos中的守护进程生成核心转储?
原标题:How to generate core dumps for daemon processes in centos?

I have some daemon processes that crashes every now and then and I want to know how I can enable core dump generations. I know that by default on linux ulimit for core dumps is zero so I need to set it to unlimited if I want to see core dumps for processes that I am running. But what I want to do is to generate core dumps for daemon processes that are running under root account. Can anyone advise me how to configure the system? Thank you in advance.

最佳回答

我相信:

ulimit -c unlimited

…或者某个值将允许您创建这些转储。此外,您可能需要查看以下网页以了解更多详细信息:如何启用核心Linux常见问题解答

问题回答

我知道,这是一个多年前的问题,但我在谷歌搜索中发现了这个问题,而公认的答案是不完整的(至少对Centos来说是这样)。

对于RHEL派生的系统,大多数守护进程都有一个init脚本,该脚本源文件名为:

/etc/sysconfig/{daemon_name}

例如,对于apache,它是:

/etc/sysconfig/httpd

这些文件中的环境变量在后台进程启动期间由init脚本读取,这些变量用于配置后台进程运行的环境。

要启用核心转储,请添加以下行:

export DAEMON_COREFILE_LIMIT= unlimited 

编辑此文件后重新启动守护程序。

您可能需要做的另一件事是更改内核核心转储文件名模板。默认情况下,核心转储将在当前工作目录中生成,并具有名称core。这并没有那么有用,因为它们会互相覆盖,而且在守护进程的情况下,它的工作目录可能(a)未知(b)不可写。要更改它:

sysctl -w kernel.core_pattern=/tmp/core_%e_%p

这个设置是我的建议,您可以更改正在使用的目录的路径和模式。上面的模式将包含可执行文件的名称和pid。

要更永久地设置它,请编辑文件/etc/sysctl.conf并插入:

kernel.core_pattern=/tmp/core_%e_%p




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签