Linux重啓Tomcat常用腳本

#!/bin/bash

# kill process
ps -ef|grep 'artworks'|grep -v 'grep'|awk '{print $2}'|xargs kill -s 9

# clean cache
rm -rf webapps/* work/* temp/*

# start tomcat
./bin/startup.sh

# monitor log
tail -f logs/catalina.out

注:ps -ef|grep 'artworks'會打印兩個進程,一個是Tomcat的進程,另一個是grep 'artworks'的進程,因此需要使用grep -v 'grep'過濾掉這條,-v表示顯示不匹配的其他行。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章