centOS7 tomcat 開機自啟 自啟動設定
阿新 • • 發佈:2019-02-19
- 編寫配置檔案
// (1)修改tomcat.service vim /lib/systemd/system/tomcat.service // (2)複製以下程式碼,注意修改tomcat路徑 [Unit] Description=tomcat After=network.target [Service] Type=oneshot ExecStart=/home/apache-tomcat-7.0.70/bin/startup.sh //自已的tomcat目錄 ExecStop=/home/apache-tomcat-7.0.70/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=multi-user.target
- 啟動服務
systemctl start tomcat.service
- 檢視服務狀態
systemctl status tomcat.service
- 設定開機啟動
systemctl enable tomcat.service
- 重啟測試
reboot