猿问

作为服务运行时,Python 脚本未启动 Bash 脚本

我有一个作为服务自动启动的 python 脚本(用 systemd 激活)。在这个 python 脚本中,我使用 .bashrc 调用了一个 bash 脚本subprocess.call(script_file,shell=True)。


当我手动调用 python 脚本 ( $ python my_python_script.py) 时,一切正常。但是,自动启动的程序不执行 bash 脚本(但是它确实运行了,我检查了这个我让它编辑了一个文本文件,它确实这样做了)。


我(认为)我给了每个人对 bash 脚本的读写权限。有没有人对我做错了什么有想法?


附录:我想编写一个小脚本,通过电报向我发送我的公共 IP 地址。服务文件如下所示:


[Unit]

Description=IPsender

After=networking.service


[Service]

Type=simple

User=root

WorkingDirectory=/home/pi/projects/tg_bot

ExecStart=/home/pi/miniconda3/bin/python /home/pi/projects/tg_bot/ip_sender_tg.py

Restart=always



[Install]

WantedBy=multi-user.target


手掌心
浏览 136回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答