sheel命令(批处理)

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>/dev/null"

alias tstart='nohup $TOMCAT_HOME/bin/startup.sh >nohup.out & 2>&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;

}

 

你可能感兴趣的:(批处理)