linux开机自启动服务
A:方式1:systemctl添加服务
一、编辑文件:sudo vim /etc/systemd/system/<服务名>.service
[Unit] Description=描述服务功能 After=network.target [Service] Type=forking ExecStart=/绝对路径/启动脚本或命令 ExecStop=/绝对路径/停止脚本或命令 Restart=always User=<运行用户> Group=<运行用户组> PrivateTmp=true [Install] WantedBy=multi-user.target
二、重新加载
sudo systemctl daemon-reload sudo systemctl enable custom.service
B:方式2: ##sudo vi /etc/rc.local
每次开机时要执行一个 hello.sh,这个脚本放在 / usr 下面,那就可以在 "/etc/rc.local" 中加一行 "/usr/./hello.sh",或者 "cd /usr/ && ./hello.sh
chmod +x /etc/rc.local
二、查看服务启动日志报错
journalctl -u docker.service

浙公网安备 33010602011771号