1、新建Python文件
test.py文件内容
print("test service ")
2、新建启动文件
testservice.sh
#!/bin/shpython3 test.py3、新建启动服务
/usr/lib/systemd/system/testservice.service
[Unit]
Description=testservice
After=network.target[Service]
ExecStart=/path/testservice.sh[Install]
WantedBy=default.target4、服务自启动
sudo systemctl enable testservice.service
 sudo systemctl status testservice.service
 sudo systemctl restart testservice.service
 sudo systemctl start testservice.service
注:宝塔python项目虚拟目录解析器
 /www/server/pyporject_evn/test_venv/bin/python3