cd /etc/systemd/system sudo vim startpic.service:
[Unit]
Description=It is startpic
[Service]
Type=simple
ExecStart=/home/ubuntu/.myenv/myfirst/bin/python /home/ubuntu/mymnt/project/myproject/wanwenyc/WWSpider/mybase/spiderXiuRenMeiMvWang.py
#启动失败之后重启
Restart=on-failure
#重启间隔为5s
RestartSec=5s
[Install]
WantedBy=multi-user.target
然后
sudo systemctl enable startpic :注册服务
sudo systemctl start startpic :注册服务
sudo service startpic status :查看startpic 服务启动状态