ubuntu-18.04 - 自定义 systemd 服务在 ubuntu 18.04 中不起作用

标签 ubuntu-18.04

当我启动此服务时,我在 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/

相关文章:

go - 无法识别ubuntu 18.04上安装的Goose

node.js - 错误: Fontconfig warning: ignoring UTF-8: not a valid region tag

kubernetes - kubectl 代理在 Ubuntu LTS 18.04 上不起作用

ubuntu - Cron 作业(python 脚本)不写 json 文件

ubuntu - Artifactory + 18.04 artifactoryManage.sh 不创建 PID 文件

ubuntu-18.04 - 我搞砸了 Steam 安装,如何修复损坏的软件包?

运行级别 3 上的 C 非阻塞键盘输入 block (Linux)

mercurial - 如何让 key 环扩展在 Ubuntu 18.04 中为 mercurial 工作?

docker - 如何使用 nsenter 实用程序从容器连接主机

c++ - 如何在openCL中运行hello world程序?