我有一个作为服务自动启动的 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
相关分类