linux - 如何知道某个进程为什么会停掉? why my process killed
访问量: 1060
参考: https://stackoverflow.com/questions/726690/what-killed-my-process-and-why
$ dmesg -T| grep -E -i -B100 'killed process'
就可以知道了.
在我的情况下,是这样的:
[Sun Dec 27 19:53:52 2020] [ 11890] 1000 11890 6571 1325 94208 0 0 bash [Sun Dec 27 19:53:52 2020] [ 20482] 1000 20482 6310244 6001210 49020928 0 0 bundle [Sun Dec 27 19:53:52 2020] [ 7650] 1000 7650 1158 19 53248 0 0 sh [Sun Dec 27 19:53:52 2020] [ 7651] 1000 7651 26903 350 241664 0 0 curl [Sun Dec 27 19:53:52 2020] [ 8096] 1000 8096 46614 1057 249856 0 0 curl [Sun Dec 27 19:53:52 2020] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice,task=bundle,pid=20482,uid=1000 [Sun Dec 27 19:53:52 2020] Out of memory: Killed process 20482 (bundle) total-vm:25240976kB, anon-rss:24002132kB, file-rss:2708kB, shmem-rss:0kB
这个进程 20482 是用户点击了导出, 直接导出9亿条数据... 导致的崩盘.
解决办法:
1. 不要导出太多数据 ( 例如关联的表等等)
2. 一点一点来. (例如, 一个月一个月的导出, 不要一次性读取一年的数据)