Centos7 添加开机启动服务
1、在/usr/lib/systemd/system/下创建服务脚本xxx.service,格式如下:
[Unit] Description=Scrapyd After=syslog.target netword.target
[Service] Type=forking ExecStart=/bin/sh /root/scrapyd/scrapyd.sh start ExecStop=/bin/sh /root/scrapyd/scrapyd.sh stop ExecReload=/bin/sh /root/scrapyd/scrapyd.sh reload PrivateTmp=True [Install] WantedBy=multi-user.target
(注:服务里面的ExecStart、ExecStop、ExecReload需要改成相应的服务的启动,关闭,重启的指令)
2.重启服务
systemctl daemon-reload # 新增脚本,重启systemctl
systemctl start xxx.service # 立即启动
systemctl enable xxx.service # 设置开启启动