3

当我启动此服务时,我在 lib/systemd/system 中有 chatbot.service,它没有给我任何错误,但它没有运行我的 python 文件。当我检查服务的状态时,它显示服务已启用但处于非活动状态。我正在从 chatbot.service 文件发送代码

[Unit]
Description=chatbot Service
After=multi-user.target
Conflicts=getty@tty1.service

[Service]
Type=simple
ExecStart=/usr/bin/python2 /home/administrator/Downloads/chatbot.py
StandardInput=tty-force``

[安装] WantedBy=multi-user.target

4

1 回答 1

1
#Create Service File

sudo vi /lib/systemd/system/dummy.service


************************************************
[Unit]
Description=Dummy Service
After=multi-user.target
Conflicts=getty@tty1.service

[Service]
Type=simple
ExecStart=<your_python_path> <python_file_path>
StandardInput=tty-force

[Install]
WantedBy=multi-user.target

*****************************************
#Enable Newly Added Service

sudo systemctl daemon-reload


sudo systemctl enable dummy.service
sudo systemctl start dummy.service


#Status of new Service

sudo systemctl status dummy.service
于 2019-10-04T07:46:51.667 回答