问题描述
我创建了一个 Python 脚本,该脚本在 5 分钟内收集信息,然后将数据发送到 aws cloudwatch。脚本的主体在一段时间内永远运行 True: 块,当我使用 python3 to_cloud.py
自行运行它时,它运行成功。
我为它做了如下服务:
[Unit]
Description=Service for sending script data to cloudwatch
After=multi-user.target
[email protected]
[Service]
Type=simple
ExecStart=/usr/bin/python3 /home/ubuntu/scripts/to_cloud.py
WorkingDirectory= /home/ubuntu/scripts
StandardInput=tty-force
[Install]
WantedBy=multi-user.target
当我启动服务时,它会在收集信息的内部循环期间运行,但随后会发生以下情况:
● to_cloud.service - Service for sending script data to cloudwatch
Loaded: loaded (/lib/systemd/system/to_cloud.service; enabled; vendor preset: enabled)
Active: Failed (Result: exit-code) since Wed 2021-06-23 16:53:44 UTC; 5s ago
Process: 191072 ExecStart=/usr/bin/python3 /home/ubuntu/scripts/to_cloud.py (code=exited,status=1/FAILURE)
Main PID: 191072 (code=exited,status=1/FAILURE)
Jun 23 16:52:43 ip-172-31-19-11 systemd[1]: Started Service for sending script data to cloudwatch.
Jun 23 16:53:44 ip-172-31-19-11 systemd[1]: to_cloud.service: Main process exited,code=exited,status=1/FAILURE
Jun 23 16:53:44 ip-172-31-19-11 systemd[1]: to_cloud.service: Failed with result 'exit-code'.
journalctl 中没有日志,所以我想知道如何找出问题所在。谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)