#!/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表示顯示不匹配的其他行。