Python文件作为服务运行(Running as a service)

/usr/lib/systemd/system文件夹下新建indexsite.service

[Unit]
Description=Index Site

[Service]
User=nobody
WorkingDirectory=/var/www/index
ExecStart=/usr/bin/env python3 server.py
Restart=always

[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload

sudo systemctl start indexsite

sudo systemctl enable indexsite

原文地址:https://www.cnblogs.com/jsben/p/15005527.html