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