简体   繁体   English

Python 脚本因 linux 中的“已终止”而停止

[英]Python script is stopped due to "Terminated" in linux

I need to run python script 24/7 in screen.我需要在屏幕上 24/7 运行 python 脚本。 But my script got "terminated" and stopped.但是我的脚本被“终止”并停止了。

I don't know why my script is stopped and show only "Terminated" message without getting any error message.我不知道为什么我的脚本被停止并且只显示“终止”消息而没有收到任何错误消息。

Therefore I run strace -p 253141 in another screen.因此我在另一个屏幕上运行strace -p 253141 I got the below message when the python script receive "Terminated".当 python 脚本收到“终止”时,我收到以下消息。

pselect6(0, NULL, NULL, NULL, {tv_sec=0, tv_nsec=0}, NULL) = 0 (Timeout)
pselect6(0, NULL, NULL, NULL, {tv_sec=0, tv_nsec=0}, NULL) = 0 (Timeout)
pselect6(-514, NULL, NULL, NULL, {tv_sec=0, tv_nsec=15232515}, NULL <unfinished ...>
--- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=253891, si_uid=1000} ---
<... pselect6 resumed> <unfinished ...>) = ?
+++ killed by SIGTERM +++

May I know why my python script stopped?我可以知道为什么我的 python 脚本停止了吗?

How can I troubleshoot the root cause?如何解决根本原因?

How can I solve this issue?我该如何解决这个问题?

The process is being killed by the OOM killer (Out Of Memory Killer), which is a process of the operating system whose job it is to kill jobs that are taking up too much memory before they crash your machine.该进程正在被 OOM 杀手 (Out Of Memory Killer) 杀死,这是操作系统的一个进程,其工作是在占用过多 memory 的作业使您的机器崩溃之前将其杀死。

Try tweaking your code, as-is it is taking up too much processing power, and thus on the verge of crashing your machine.尝试调整你的代码,因为它占用了太多的处理能力,因此濒临崩溃你的机器。

This answer is for the Unix OS, but because they are so similar, maybe it will work:这个答案适用于 Unix 操作系统,但因为它们非常相似,所以它可能会起作用:

https://unix.stackexchange.com/questions/614950/python-programs-suddenly-get-killed?adlt=strict&toWww=1&redig=5673AE4D36F84AF8A2CA9EB5A1E3EA62 https://unix.stackexchange.com/questions/614950/python-programs-suddenly-get-killed?adlt=strict&toWww=1&redig=5673AE4D36F84AF8A2CA9EB5A1E3EA62

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM