2015年(55)
分类: LINUX
2015-01-23 15:23:10
linux快捷方式启动tomcat
1.脚本路径 /etc/init.d/tomcat
首先执行: vi /etc/init.d/tomcat
按 a 编辑,将下面内容根据你自己的情况(主要是修改 /usr/local/tomcat6/bin/ )
修改后copy到编辑框中, esc 退出编辑,:wq 保存退出
Java代码
# !/bin/bash
# Description: start or stop the tomcat
# Usage: tomcat [start|stop|reload|restart]
#
export PATH=$PATH:$HOME/bin
export BASH_ENV=$HOME/.bashrc
export USERNAME="root"
case "$1" in
start)
#startup the tomcat
echo -n "tomcat start: "
cd /home/tomcat-bdcServer/bin
./startup.sh
echo " Tomcat 已启动"
tail -f /home/tomcat-bdcServer/logs/log.log#打印日志
;;
stop)
# stop tomcat
echo -n "tomcat stop:"
ps -ef | grep "" | grep -v grep | sed 's/ [ ]*/:/g'|cut -d: -f2| kill -9 `cat`
cd /usr/local/6/work
rm -rf Catalina
echo "Tomcat 已停止"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "用法: tomcat [start|stop|reload|restart]"
exit 1
esac
exit 0
2.更改tomcat脚本为可执行文件
Java代码
chmod +x /etc/init.d/tomcat
3.为了在任意路径都可执行此脚本,需要添加到/usr/bin目录中
Java代码
1.[root@localhost]# /usr/bin
2. [root@localhost]# ln -s /etc/init.d/tom .