linux 設置tomcat快捷啟動方式
阿新 • • 發佈:2018-01-31
cat tope ase 自己的 cas 方式 tar $1 brush
在linux下搭建好tomcat之後,每次啟動和關閉都要去tomcat的bin目錄下執行./startup.sh和./shutdown.sh
這是很不方便的,下面介紹如何像執行ls mv cp等命令一樣啟動,關閉,重啟tomcat
第一步創建腳本
腳本創建路徑 /etc/init.d/tomcat
首先執行: vim /etc/init.d/tomcat 將下面內容根據你自己的情況(修改/usr/tomcat/apache-tomcat-8.5.23/bin為你的tomcat路徑) d刪除 y復制 p粘貼# !/bin/bash # Description: start or stop the tomcat # Usage: tomcat [start|stop|restart] # export PATH=$PATH:$HOME/bin export BASH_ENV=$HOME/.bashrc export USERNAME="root" case "$1" in start) #startup the tomcat cd /usr/tomcat/apache-tomcat-8.5.23/bin ./startup.sh ;; stop) # stop tomcat cd /usr/tomcat/apache-tomcat-8.5.23/bin ./shutdown.sh echo "Tomcat Stoped" ;; restart) $0 stop $0 start ;; *) echo "tomcat: usage: tomcat [start|stop|restart]" exit 1 esac exit 0
添加執行權限
chmod +x /etc/init.d/tomcat
創建軟鏈接
cd /usr/bin
ln -s /etc/init.d/tomcat
測試
tomcat start
tomcat stop
tomcat restart
linux 設置tomcat快捷啟動方式