新建nexus启动脚本
进入/etc/init.d目录,新建脚本文件nexus
// 进入/etc/init.d
[root@linux_maven etc]# cd /etc/init.d/
// 新建脚本文件nexus
[root@linux_maven init.d]# vim nexus
脚本内容:
#!/bin/bash
#chkconfig:2345 20 90
#description:nexus
#processname:nexus
export JAVA_HOME=/root/apps/jdk1.8/
case $1 in
start) su root /home/nexus/nexus-3.24.0-02/bin/nexus start;;
stop) su root /home/nexus/nexus-3.24.0-02/bin/nexus stop;;
status) su root /home/nexus/nexus-3.24.0-02/bin/nexus status;;
restart) su root /home/nexus/nexus-3.24.0-02/bin/nexus restart;;
dump) su root /home/nexus/nexus-3.24.0-02/bin/nexus dump;;
console) su root /home/nexus/nexus-3.24.0-02/bin/nexus console;;
*) echo "Usage: nexus {start|stop|run|run-redirect|status|restart|force-reload}"
esac
设置脚本权限
[root@linux_maven init.d]# chmod +x /etc/init.d/nexus
使用service命令使用nexus
[root@linux_maven init.d]# service nexus status
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
nexus is running.
添加到开机启动
[root@linux_maven init.d]# chkconfig nexus on
查看nexus开机启动
[root@linux_maven ~]# chkconfig --list nexus
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
nexus 0:off 1:off 2:on 3:on 4:on 5:on 6:off
如果无法访问,检查一下防火墙端口是否开放。