1.sudo vim /etc/systemd/system/django_ops.service
2.填入以下内容
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
[Unit] Description=My Custom Service After=network.target [Service] ExecStart=/data/soft/django_ops/django_ops.sh Restart=always [Install] WantedBy=multi-user.targetView Code
3.所用脚本内容
/data/soft/django_ops/django_ops.sh
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#!/bin/bash python3 /data/soft/django_ops/manage.py runserver 0.0.0.0:8000View Code
4.可以执行以下命令
sudo systemctl daemon-reload # 重新加载所有的服务
sudo systemctl start django_ops.service # 启动你的服务
sudo systemctl enable django_ops.service # 设置服务开机自启
5.过程不顺利的话可以使用一下查看日志报错
sudo journalctl -u django_ops.service
6.查看开机自启的程序列表
systemctl list-unit-files --type=service | grep enabled
标签:系统启动,service,ops,sudo,django,systemctl,linux,开机 From: https://www.cnblogs.com/wusenwusen/p/17664433.html