Systemd开启coredump转储文件

配置系统 core文件路径:

1
2
3
4
添加:kernel.core_pattern
[root@localhost tmp]# vim /etc/sysctl.conf
kernel.core_pattern=/mydata/corefile/core-%e-%s-%u-%g-%p-%t
[root@localhost tmp]#

使配置生效

1
2
3
[root@localhost tmp]# sysctl -p
kernel.core_pattern = /mydata/corefile/core-%e-%s-%u-%g-%p-%t
[root@localhost tmp]#

修改服务,支持LimitCORE:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@localhost ~]# cat /lib/systemd/system/chunli_test.service
[Unit]
Description=chunli_test
After=network.target

[Service]
LimitCORE=infinity
ExecStart=/tmp/while
Restart=always
StartLimitInterval=0

[Install]
WantedBy=multi-user.target
[root@localhost ~]#

服务重载

1
[root@localhost ~]# systemctl  daemon-reload

程序重启:

1
systemctl  restart yaWxDpi