1、新建服务脚本
vim/etc/init.d/nexus
添加以下脚本内容
#!/bin/bash
#chkconfig:23452090
#description:nexus
#processname:nexus
exportJAVA_HOME=/usr/local/jdk1.8.0_60
case$1in
start)suroot/usr/local/nexus-3.12.1-01/bin/nexusstart;;
stop)suroot/usr/local/nexus-3.12.1-01/bin/nexusstop;;
status)suroot/usr/local/nexus-3.12.1-01/bin/nexusstatus;;
restart)suroot/usr/local/nexus-3.12.1-01/bin/nexusrestart;;
dump)suroot/usr/local/nexus-3.12.1-01/bin/nexusdump;;
console)suroot/usr/local/nexus-3.12.1-01/bin/nexusconsole;;
*)echo"Usage:nexus{start|stop|run|run-redirect|status|restart|force-reload}"
esac
配置完后,保存退出
2、给新建的脚本设置执行权限
chmod744/etc/init.d/nexus
3、执行以下命令进行启动、停止和重启nexus服务
#启动
servicenexusstart
#停止
servicenexusstop
#重启
servicenexusrestart
#查看nexus的状态
servicenexusstatus
二、配置nexus服务开机自启动
#向chkconfig添加nexus服务的管理
chkconfig--addnexus
#设置nexus服务自启动
chkconfignexuson
#关闭nexus服务自启动
chkconfignexusoff
#删除nexus服务在chkconfig上的管理
chkconfig–delnexus
这样就成功配置了nexus在linux下开机自启动
|