python-3.x - shell和systemd之间的stderr输出不一致
问题描述
我在启动时运行了一个小脚本:
起初我使用带有@reboot标签的 crontab,但是,由于有时我需要修改脚本,我最终查看了 systemd 以便轻松重新启动脚本
我的 crontab 配置是:
@reboot sleep 10; cd /path/to/the/script/ && nohup ./script.py >> stdout.txt 2>> stderr.txt
一切正常
我现在正在使用带有此配置的 systemd:
[Unit]
Description=Script
[Service]
WorkingDirectory=/path/to/the/script/
ExecStart=/path/to/the/script/script.py
StandardOutput=file:/path/to/the/script/stdout.txt
StandardError=file:/path/to/the/script/stderr.txt <----- Problem here
User=my_user
[Install]
WantedBy=graphical.target
问题是:
- 在 stderr 正确写入 stderr.txt 之前
- 现在 stdout 和 stderr 都被写入 stdout.txt,即使我为 stderr 指定了不同的文件
看也没有错误
journalctl -e -u python-coolosseo
顺便说一句,我尝试了两个文件:并附加:
解决方案
推荐阅读
- arrays - Vue.js 方法返回过时的数组数据
- python - 确定 TD 标签内的类
- templates - 如何在样式范围内添加类?
- java - 性能与稍微干净的代码:在循环之前和循环期间检查属性
- react-native - 在导航器中的何处放置重置堆栈功能?
- node.js - 如何使用 node.js 和 MongoDB Atlas 删除数据库?
- php - 我的登录没有重定向到我在 PHP 中的索引
- typescript - 将 Typescript 的类型交集与可区分的联合使用时出现意外的类型错误
- mouseevent - 当我将鼠标悬停在 Wix 元素上时,它会打开和关闭吗?
- php - 无法为每个重新声明函数错误