linux中设置nexus开机自启动的方法

来自:网络
时间:2024-06-08
阅读:

一、把nexus配置成服务

1、新建服务脚本

vim /etc/init.d/nexus

添加以下脚本内容

#!/bin/bash
#chkconfig:2345 20 90
#description:nexus
#processname:nexus
 
export JAVA_HOME=/usr/local/jdk1.8.0_60
 
case $1 in
        start) su root /usr/local/nexus-3.12.1-01/bin/nexus start;;
        stop) su root /usr/local/nexus-3.12.1-01/bin/nexus stop;;
        status) su root /usr/local/nexus-3.12.1-01/bin/nexus status;;
        restart) su root /usr/local/nexus-3.12.1-01/bin/nexus restart;;
        dump) su root /usr/local/nexus-3.12.1-01/bin/nexus dump;;
        console) su root /usr/local/nexus-3.12.1-01/bin/nexus console;;
        *) echo "Usage: nexus {start|stop|run|run-redirect|status|restart|force-reload}"
esac

配置完后,保存退出

2、给新建的脚本设置执行权限

chmod 744 /etc/init.d/nexus

3、执行以下命令进行启动、停止 和 重启nexus服务

#启动
service nexus start
 
#停止
service nexus stop
 
#重启
service nexus restart
 
#查看nexus的状态
service nexus status

二、配置nexus服务开机自启动

#向chkconfig添加 nexus 服务的管理
chkconfig --add nexus
 
#设置nexus服务自启动
chkconfig nexus on
 
#关闭nexus服务自启动
chkconfig nexus off
 
#删除nexus服务在chkconfig上的管理
chkconfig –del nexus

这样就成功配置了nexus在linux下开机自启动

返回顶部
顶部