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私服