版权声明:欢迎大家转载: https://blog.csdn.net/u012377333/article/details/85047446
接上文《基于CentOS6.5安装Nexus》
1、新建nexus启动脚本
进入/etc/init.d目录,新建脚本文件nexus
# vim /etc/init.d/nexus
脚本内容
#!/bin/bash
#chkconfig:2345 20 90
#description:nexus
#processname:nexus
export JAVA_HOME=/opt/server/jdk1.8.0_51
case $1 in
start) su root /usr/local/nexus-3.14.0-04/bin/nexus start;;
stop) su root /usr/local/nexus-3.14.0-04/bin/nexus stop;;
status) su root /usr/local/nexus-3.14.0-04/bin/nexus status;;
restart) su root /usr/local/nexus-3.14.0-04/bin/nexus restart;;
dump) su root /usr/local/nexus-3.14.0-04/bin/nexus dump;;
console) su root /usr/local/nexus-3.14.0-04/bin/nexus console;;
*) echo "Usage: nexus {start|stop|run|run-redirect|status|restart|force-reload}"
esac
2、给脚本设置权限
# chmod +x /etc/init.d/nexus
3、使用service命令使用nexus
# service nexus status
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
nexus is running.
4、添加到开机启动
# chkconfig --add nexus
5、查看nexus开机启动
# chkconfig --list nexus
nexus 0:off 1:off 2:on 3:on 4:on 5:on 6:off