1.简介
init.d 和 systemd 是负责Ubuntu 和 CentOS程序自启动命令框架。
2.软链接ln
创建程序用户xxx ln -s /usr/local/nexus-3.16.0-01/bin/nexus /etc/init.d/nexus cd /etc/init.d chkconfig --add nexus chkconfig --levels 345 nexus on service nexus start
3.使用systemd脚本
vi /etc/systemd/system/nexus.service [Unit] Description=nexus service After=network.target [Service] Type=forking LimitNOFILE=65536 ExecStart=/usr/local/nexus-3.16.0-01/bin/nexus start ExecStop=/usr/local/nexus-3.16.0-01/bin/nexus stop User=nexus Restart=on-abort [Install] WantedBy=multi-user.target
3.1增加脚本执行
chmod a+x nexus.service
3.2激活
systemctl daemon-reload systemctl enable nexus.service
3.3 重启后查看启动情况
tail -f /usr/local/sonatype-work/nexus3/log/nexus.log