centos8 nexus3 & tomcat8.5 开机自启动

centos8 nexus3 & tomcat8.5 开机自启动

一、Nexus3开机自启动:
1、在/etc/init.d下创建服务脚本nexus,并且在脚本里面添加以下代码:(其中export NEXUS_HOME指向的是当前centos安装nexus的bin所在路径下)

#!/bin/bash 
#chkconfig:2345 20 90
#description:nexus
#processname:nexus
 
export NEXUS_HOME=/usr/local/nexus/nexus-3.9.0-01
 
case $1 in    
        start) su root $NEXUS_HOME/bin/nexus start;;    
        stop) su root $NEXUS_HOME/bin/nexus stop;;    
        status) su root $NEXUS_HOME/bin/nexus status;;    
        restart) su root $NEXUS_HOME/bin/nexus restart;;    
        dump ) su root $NEXUS_HOME/bin/nexus dump ;; 
        console ) su root $NEXUS_HOME/bin/nexus console ;;          
        *) echo "require console | start | stop | restart | status | dump " ;;    
esac

2、给nexus脚本设置可执行权限

chmod +x /etc/init.d/nexus

在这里插入图片描述
3、Nexus3配置开机自启动

//添加该服务
chkconfig --add nexus
//设置自启动
chkconfig nexus on

至此,nexus开机自启动已经配置完成,可以采用以下命令便捷使用:

//查看当前nexus状态
service nexus status

在这里插入图片描述
启动:service nexus start
停止:service nexus stop
重启:service nexus restart
在这里插入图片描述
ps:

关闭nexus服务自启动:chkconfig nexus off

删除nexus服务在chkconfig上的管理:chkconfig –del nexus

二、Tomcat8.5开机自启动:
1、同理,在/etc/init.d下创建服务脚本tomcat,并且在脚本里面添加以下代码:(其中CATALINA_HOME指向的是当前centos安装tomcat所在路径)

#!/bin/bash
#cription: Tomcat Start Stop Restart
# processname: tomcat8
# chkconfig: 234 20 80

CATALINA_HOME=/usr/local/tomcat

case $1 in
        start)
                sh $CATALINA_HOME/bin/startup.sh
                ;;
        stop)
                sh $CATALINA_HOME/bin/shutdown.sh
                ;;
        restart)
                sh $CATALINA_HOME/bin/shutdown.sh
                sh $CATALINA_HOME/bin/startup.sh
                ;;
        *)
                echo 'please use : tomcat {start | stop | restart}'
        ;;
esac

2、给tomcat脚本设置可执行权限

chmod +x /etc/init.d/tomcat

在这里插入图片描述
如果你的/etc/init.d下已经存在tomcat开头的服务脚本,说明你之前已经创建该tomcat的脚本,或者你已经安装了其他版本的tomcat,安装时已经自动添加了开机自启动的脚本(比如你在宝塔上面的软件商店安装tomcat就会自动创建开机自启动脚本,我上面的tomcat8脚本就是这样子)
3、Tomcat8.5配置开机自启动

//添加该服务
chkconfig --add tomcat
//设置自启动
chkconfig tomcat on

至此,tomcat开机自启动已经配置完成,可以采用以下命令便捷使用:

启动:service tomcat start
停止:service tomcat stop
重启:service tomcat restart

//查看tomcat的启动状态
chkconfig --list | grep tomcat

在这里插入图片描述
以上就是全部开机自启动的设置。
Best regards

Click here: 使用阿里云centos8搭建nexus3私服

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值