王大拿
知道的越多,不知道的也就越多! 只要学不死,就往死里学!!!

编写开机自启动脚本

进入到开机自启动调用文件目录

vim /etc/systemd/system/sonarqube.service
[Unit]
Description=SonarQube service
After=syslog.target network.target
[Service]
Type=forking
//根据自己安装目录的启动路径填写
ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
//填写启动sonarqube的授权用户和用户组
User=sonar_user
Group=sonar_user
Restart=always
//linux启动调优
LimitNOFILE=65536
LimitNPROC=10240
[Install]
WantedBy=multi-user.target

image

启用服务器重启后自动启动 sonarqube 服务

[root@Sonnarqube-dev ~]# systemctl enable sonarqube.service

查看开机自启动服务列表

[root@Sonnarqube-dev ~]# systemctl list-unit-files

image

查看sonarqube的开机自启动服务

[root@Sonnarqube-dev ~]# systemctl status sonarqube.service -l

image

重启测试

[root@Sonnarqube-dev ~]#reboot

等待片刻后查看进程

[root@Sonnarqube-dev ~]# ss -ltn

image

查看网页

image
至此开机自启动设置成功。

posted on 2021-07-04 17:08  DevOps_SRE  阅读(816)  评论(0)    收藏  举报