How to enable core dumps for systemd services on CentOS 7?
(1) change the core_pattern to some place you could write to
$ cat /proc/sys/kernel/core_pattern
/home/your-user-name/coredumps/core-%e-sig%s-user%u-group%g-pid%p-time%t
Note: your-user-name is the user name you are using to run your program which would crash to generate a core dump.
(2) create a new file:
/etc/security/limits.d/core.conf
like:
to enable core dumps for all users* hard core unlimited
* soft core unlimited
(3) modify /etc/systemd/system.conf
to add:
DefaultLimitCORE=infinity
(4) modify your systemd service conf
e.g., /etc/systemd/system/your-service.service
to add:
LimitCORE=infinityin the "[Service]" section.
(5) reload the new systemd conf and restart your service
(6) how to test itsystemctl daemon-reexec
systemctl stop your-service
systemctl start your-service
You could kill your service process by sending signal 11 (SIGSEGV) to your process. By right, you should see a new core dump at:
/home/your-user-name/coredumps/core-%e-sig%s-user%u-group%g-pid%p-time%t
References:
http://www.kibinlabs.com/re-enabling-core-dumps-redhat-7/
2 comments:
Thank you so much! It is hard to find info on how to get systemd processes to create a core on CentOS 7.
thank you so much for all
Post a Comment