Centos7設置systemctl開啓啓動

Centos7設置systemctl開啓啓動

參考博客

  1. centos7 systemctl 方式添加啓動項
  2. systemctl start tomcat 啓動報錯JAVA_HOME不能存在

配置系統文件

  1. 打開啓動項配置目錄:cd /lib/systemd/system/
  2. 新建自己的服務: touch tomcat-jenkins.service
  3. 編輯新建服務: vim tomcat-jenkins.service
    複製粘貼到文件裏面
    [Unit]
    Description=tomcat-jenkins
    After=network.target
    
    [Service]
    Type=forking
    ExecStart=/opt/tomcat/tomcat-jenkins/bin/startup.sh
    ExecStop=/opt/tomcat/tomcat-jenkins/bin/shutdown.sh
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    
    

啓動

  1. 啓動命令: systemctl start tomcat-jenkins
    1. 啓動可能失敗: Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
    2. 解決鏈接:systemctl start tomcat 啓動報錯JAVA_HOME不能存在
  2. 關閉命令: systemctl stop tomcat-jenkins
  3. 查看tomcat運行狀態: systemctl status tomcat-jenkins
  4. 設置開啓啓動: systemctl enable tomcat-jenkins
  5. 刪除開機啓動: systemctl disable tomcat-jenkins
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章