-
创建配置文件
vim /etc/systemd/system/your-service.service
-
写入如下内容
[Unit] Description=My Custom Service After=network.target [Service] Type=simple ExecStart=/usr/bin/python3 /path/to/your/script.py Restart=on-failure [Install] WantedBy=multi-user.target
-
reload守护进程
systemctl daemon-reload
-
start自定义进程
systemctl start your-service
-
开机自启动