我有一个 python 脚本,我通常使用以下命令运行它:
(environment) python run.py
我想在开始时运行这个脚本。(我正在使用 ubuntu)这是我的服务:
[Unit]
Description=My Script Service
After=multi-user.target
[Service]
Type=idle
ExecStart=/home/user/anaconda3/bin/python /home/user/space/run.py
[Install]
WantedBy=multi-user.target
顺便说一句,我无法运行此脚本,但我可以运行不在环境中的任何脚本。如何在启动时运行 python 脚本(virtualenv)?
sudo systemctl status user_sent
● user_sent.service - Mail Service
Loaded: loaded (/lib/systemd/system/user_sent.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since xxxxx 16:30:20 MSK; 3s ago
Process: 3713 ExecStart=/usr/bin/python run.py (code=exited, status=200/CHDIR)
Main PID: 3713 (code=exited, status=200/CHDIR)