linux为了可以更方便的启动|关闭|重启 tomcat,做个脚本
脚本路径/etc/init.d/tomcat
首先执行:vi/etc/init.d/tomcat
按a编辑,将下面内容根据你自己的情况(主要是修改/usr/local/tomcat6/bin/)
修改后copy到编辑框中,esc退出编辑,:wq保存退出
------------------
-----脚本内容-----
------------------
# !/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 /usr/local/tomcat6/bin/ ./startup.sh echo " Tomcat start finished" ;; stop) # stop tomcat echo -n "tomcat stop:" ps -ef | grep "java" | grep -v grep | sed 's/ [ ]*/:/g'|cut -d: -f2| kill -9 `cat` cd /usr/local/tomcat6/work rm -rf Catalina echo "finished" ;; reload|restart) $0 stop $0 start ;; *) echo "Usage: tomcat [start|stop|reload|restart]" exit 1 esac exit 0
---------------------
更改tomcat脚本为可执行文件
引用
[root@localhost]# chmod +x /etc/init.d/tomcat
为了在任意路径都可执行此脚本,需要添加到/usr/bin目录中
引用
[root@localhost]# cd /usr/bin [root@localhost]# ln -s /etc/init.d/tomcat .
相关推荐
linuxwcj 2020-10-21
彼岸随笔 2020-10-20
yutou0 2020-10-17
jarrygao 2020-11-02
shipinsky 2020-09-23
touchfuture 2020-09-16
hongsheyoumo 2020-09-04
momoku 2020-09-11
ruancw 2020-08-27
TuxedoLinux 2020-08-18
vvu 2020-08-16
downtown 2020-08-11
luvzhan 2020-07-28
maxelliot 2020-06-28
cuixingwudi 2020-06-25
linuxdashencom 2020-06-21
旭灿 2020-06-16
wenjieyatou 2020-06-14