CentOS7配置nexus开机自启动

迈不过友情╰ 2022-12-13 09:54 852阅读 0赞

新建nexus启动脚本

进入/etc/init.d目录,新建脚本文件nexus

  1. // 进入/etc/init.d
  2. [root@linux_maven etc]# cd /etc/init.d/
  3. // 新建脚本文件nexus
  4. [root@linux_maven init.d]# vim nexus

脚本内容:

  1. #!/bin/bash
  2. #chkconfig:2345 20 90
  3. #description:nexus
  4. #processname:nexus
  5. export JAVA_HOME=/root/apps/jdk1.8/
  6. case $1 in
  7. start) su root /home/nexus/nexus-3.24.0-02/bin/nexus start;;
  8. stop) su root /home/nexus/nexus-3.24.0-02/bin/nexus stop;;
  9. status) su root /home/nexus/nexus-3.24.0-02/bin/nexus status;;
  10. restart) su root /home/nexus/nexus-3.24.0-02/bin/nexus restart;;
  11. dump) su root /home/nexus/nexus-3.24.0-02/bin/nexus dump;;
  12. console) su root /home/nexus/nexus-3.24.0-02/bin/nexus console;;
  13. *) echo "Usage: nexus {start|stop|run|run-redirect|status|restart|force-reload}"
  14. esac

设置脚本权限

  1. [root@linux_maven init.d]# chmod +x /etc/init.d/nexus

使用service命令使用nexus

  1. [root@linux_maven init.d]# service nexus status
  2. WARNING: ************************************************************
  3. WARNING: Detected execution as "root" user. This is NOT recommended!
  4. WARNING: ************************************************************
  5. nexus is running.

添加到开机启动

  1. [root@linux_maven init.d]# chkconfig nexus on

查看nexus开机启动

  1. [root@linux_maven ~]# chkconfig --list nexus
  2. Note: This output shows SysV services only and does not include native
  3. systemd services. SysV configuration data might be overridden by native
  4. systemd configuration.
  5. If you want to list systemd services use 'systemctl list-unit-files'.
  6. To see services enabled on particular target use
  7. 'systemctl list-dependencies [target]'.
  8. nexus 0:off 1:off 2:on 3:on 4:on 5:on 6:off

如果无法访问,检查一下防火墙端口是否开放。

发表评论

表情:
评论列表 (有 0 条评论,852人围观)

还没有评论,来说两句吧...

相关阅读