linux服务启动python
- 服务文件 edgePython.service
[Unit]
Description=edgePythonService
RefuserManualStop=yes
[Service]
Type=simple
User=root
Group=root
#设置应用的工作目录
WorkingDirectory=/root
ExecStart=python /root/esms/py/run.py
Restart=always
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
- 说明
# /etc/systemd/system 目录 建立改文件
# 重载 systemctl daemon-reload
# 启动 停止 查看 systemctl start/stop/status edgePython.service
# 若报python不存在,将安装好的python 链到不存在位置,如:ln -s /usr/local/python /usr/sbin/
# 开机启动、停止 systemctl enable\disable edgePython.service
# 查看 服务日志 journalctl -u edgePython.service -f