首页 > 解决方案 > 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

问题是:


看也没有错误

journalctl -e -u python-coolosseo

顺便说一句,我尝试了两个文件:并附加:

标签: python-3.xubuntusystemd

解决方案


推荐阅读