当我启动此服务时,我在 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
最佳答案
#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
关于ubuntu-18.04 - 自定义 systemd 服务在 ubuntu 18.04 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50756814/