---
title: "sheel命令(批处理)"
author: "wawa129"
date: "2015-01-09T09:08:04Z"
tags: []
categories: ["企业架构"]
slug: "sheel"
draft: false
lastmod: "2015-01-09T09:08:04Z"
id: 2174172
url: "https://wawa129.iteye.com/blog/2174172"
---

1:当前我的们的tomcat,java项目都是用一个批处理命令处理的（包括kill,start,log等）

 

     执行doall即执行所有命令：

 

   2:编写方法

 

目录：/root/.bash\_profile

 

 

.bash\_profile 文件的内容如下：

 

\# .bash\_profile

 

\# Get the aliases and functions

if \[ -f ~/.bashrc ]; then

. ~/.bashrc

fi

 

\# User specific environment and startup programs

 

PATH=$PATH:$HOME/bin

 

export PATH

unset USERNAME

export JAVA\_HOME=/usr/local/java

export CLASSPATH=$JAVA\_HOME/lib

export PATH=$PATH:$JAVA\_HOME/bin

 

#for tomcat

export TOMCAT\_HOME=/usr/local/tomcat

 

alias tstop="ps -ef|grep tomcat|grep -v grep|awk '{print \\$2}'|xargs kill -9 2&gt;/dev/null"

alias tstart='nohup $TOMCAT\_HOME/bin/startup.sh &gt;nohup.out & 2&gt;&1'

alias tailt='tail -f $TOMCAT\_HOME/logs/catalina.out'

alias tclear='rm -rf $TOMCAT\_HOME/work/Catalina/localhost/\_/\*'

alias taillog='tail -f /var/www/logs/server.log'

alias tailjob='tail -f /var/www/logs/web.log'

 

doall() {

  tstop;

  sleep 2;

  tclear;

  tstart;

  tailt;

}