python - python脚本失败时记录

标签 python linux python-3.x logging gnu-screen

我在我的服务器上通过 screen session 运行一个相当复杂的 python 脚本。有时,几个小时后,它会崩溃,我不明白为什么。由于脚本在 screen 上运行,当脚本崩溃时我无法访问错误。有什么方法可以通过日志记录或简单的管道提取该信息吗?

最佳答案

您可以使用nohup& 在后台运行您的python 命令。默认输出将在 nohup.out 文件中记录任何打印输出(包括终止脚本的错误)。您可以使用 >

在 Bash 中指定文件输出

例如

nohup python my_python_script.py > my_output_log &

关于python - python脚本失败时记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55387261/

相关文章:

python - PyQt、Python 3 : Lambda slot assigning signal argument to a variable?

Python Linux 读取进程内存 - int 太大而无法转换为 C long

python - 在python中实现LZ78压缩算法

python - 对我来说最重要的问题 : is there a better way off doing it and if there is, 你们能给我指出正确的方向吗?

java - 错误 : Could not find or load main class ( in Java 8)

python - 在生成字典时高效地处理大量字符串

python - 如何使用调试信息记录 Python 错误?

linux - ubuntu启动黑屏

linux - 如何在 ALSA 中获取 PCM 设备路径?

python - 安装基于 pyproject.toml 的项目所需的错误 : Could not build wheels for pycocotools,