精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2005-08-22
操作系统:linux 服务器: tomcat 数据库: oracle[/list] 配置文件: #!/bin/sh # ----------------------------------------------------------------------------- # Start/Stop Script for the CATALINA Server # # Environment Variable Prequisites # # CATALINA_HOME May point at your Catalina "build" directory. # # CATALINA_BASE (Optional); Base directory for resolving dynamic portions # of a Catalina installation. If not present, resolves to # the same directory that CATALINA_HOME points to. # # CATALINA_OPTS (Optional); Java runtime options used when the "start", # "stop", or "run" command is executed. # # CATALINA_TMPDIR (Optional); Directory path location of temporary directory # the JVM should use (java.io.tmpdir);. Defaults to # $CATALINA_BASE/temp. # # JAVA_HOME Must point at your Java Development Kit installation. # # JAVA_OPTS (Optional); Java runtime options used when the "start", # "stop", or "run" command is executed. # # JPDA_TRANSPORT (Optional); JPDA transport used when the "jpda start" # command is executed. The default is "dt_socket". # # JPDA_ADDRESS (Optional); Java runtime options used when the "jpda start" # command is executed. The default is 8000. # # JSSE_HOME (Optional); May point at your Java Secure Sockets Extension # (JSSE); installation, whose JAR files will be added to the # system class path used to start Tomcat. # # CATALINA_PID (Optional); Path of the file which should contains the pid # of catalina startup java process, when start (fork); is used # # $Id: catalina.sh,v 1.13 2004/05/26 19:45:33 yoavs Exp $ # ----------------------------------------------------------------------------- # OS specific support. $var _must_ be set to either true or false. cygwin=false os400=false case "`uname`" in CYGWIN*); cygwin=true;; OS400*); os400=true;; esac # resolve links - $0 may be a softlink PRG="$0" while [ -h "$PRG" ]; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\);$'` if expr "$link" : '.*/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`/"$link" fi done # Get standard environment variables PRGDIR=`dirname "$PRG"` CATALINA_HOME=`cd "$PRGDIR/.." ; pwd` if [ -r "$CATALINA_HOME"/bin/setenv.sh ]; then . "$CATALINA_HOME"/bin/setenv.sh fi # For Cygwin, ensure paths are in UNIX format before anything is touched if $cygwin; then [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` [ -n "$CATALINA_HOME" ] && CATALINA_HOME=`cygpath --unix "$CATALINA_HOME"` [ -n "$CATALINA_BASE" ] && CATALINA_BASE=`cygpath --unix "$CATALINA_BASE"` [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"` [ -n "$JSSE_HOME" ] && JSSE_HOME=`cygpath --path --unix "$JSSE_HOME"` fi # For OS400 if $os400; then # Set job priority to standard for interactive (interactive - 6); by using # the interactive priority - 6, the helper threads that respond to requests # will be running at the same priority as interactive jobs. COMMAND='chgjob job('$JOBNAME'); runpty(6);' system $COMMAND # Enable multi threading export QIBM_MULTI_THREADED=Y fi # Get standard Java environment variables if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then BASEDIR="$CATALINA_HOME" . "$CATALINA_HOME"/bin/setclasspath.sh else echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh" echo "This file is needed to run this program" exit 1 fi # Add on extra jar files to CLASSPATH if [ -n "$JSSE_HOME" ]; then CLASSPATH="$CLASSPATH":"$JSSE_HOME"/lib/jcert.jar:"$JSSE_HOME"/lib/jnet.jar:"$JSSE_HOME"/lib/jsse.jar fi CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HOME"/bin/commons-logging-api.jar if [ -z "$CATALINA_BASE" ] ; then CATALINA_BASE="$CATALINA_HOME" fi if [ -z "$CATALINA_TMPDIR" ] ; then # Define the java.io.tmpdir to use for Catalina CATALINA_TMPDIR="$CATALINA_BASE"/temp fi # For Cygwin, switch paths to Windows format before running java if $cygwin; then JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` CATALINA_HOME=`cygpath --path --windows "$CATALINA_HOME"` CATALINA_BASE=`cygpath --path --windows "$CATALINA_BASE"` CATALINA_TMPDIR=`cygpath --path --windows "$CATALINA_TMPDIR"` CLASSPATH=`cygpath --path --windows "$CLASSPATH"` JSSE_HOME=`cygpath --path --windows "$JSSE_HOME"` JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"` fi # ----- Execute The Requested Command ----------------------------------------- echo "Using CATALINA_BASE: $CATALINA_BASE" echo "Using CATALINA_HOME: $CATALINA_HOME" echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR" echo "Using JAVA_HOME: $JAVA_HOME" if [ "$1" = "jpda" ] ; then if [ -z "$JPDA_TRANSPORT" ]; then JPDA_TRANSPORT="dt_socket" fi if [ -z "$JPDA_ADDRESS" ]; then JPDA_ADDRESS="8000" fi if [ -z "$JPDA_OPTS" ]; then JPDA_OPTS="-Xdebug -Xrunjdwp:transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=n" fi CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS" shift fi if [ "$1" = "debug" ] ; then if $os400; then echo "Debug command not available on OS400" exit 1 else shift if [ "$1" = "-security" ] ; then echo "Using Security Manager" shift exec "$_RUNJDB" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -sourcepath "$CATALINA_HOME"/../../jakarta-tomcat-catalina/catalina/src/share \ -Djava.security.manager \ -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" start else exec "$_RUNJDB" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -sourcepath "$CATALINA_HOME"/../../jakarta-tomcat-catalina/catalina/src/share \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" start fi fi elif [ "$1" = "run" ]; then shift if [ "$1" = "-security" ] ; then echo "Using Security Manager" shift exec "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -Djava.security.manager \ -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" start else exec "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" start fi elif [ "$1" = "start" ] ; then shift touch "$CATALINA_BASE"/logs/catalina.out if [ "$1" = "-security" ] ; then echo "Using Security Manager" shift "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -Djava.security.manager \ -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" start \ >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & if [ ! -z "$CATALINA_PID" ]; then echo $! > $CATALINA_PID fi else "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" start \ >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & if [ ! -z "$CATALINA_PID" ]; then echo $! > $CATALINA_PID fi fi elif [ "$1" = "stop" ] ; then shift FORCE=0 if [ "$1" = "-force" ]; then shift FORCE=1 fi "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" stop if [ $FORCE -eq 1 ]; then if [ ! -z "$CATALINA_PID" ]; then echo "Killing: `cat $CATALINA_PID`" kill -9 `cat $CATALINA_PID` fi fi else echo "Usage: catalina.sh ( commands ... );" echo "commands:" if $os400; then echo " debug Start Catalina in a debugger (not available on OS400);" echo " debug -security Debug Catalina with a security manager (not available on OS400);" else echo " debug Start Catalina in a debugger" echo " debug -security Debug Catalina with a security manager" fi echo " jpda start Start Catalina under JPDA debugger" echo " run Start Catalina in the current window" echo " run -security Start in the current window with security manager" echo " start Start Catalina in a separate window" echo " start -security Start in a separate window with security manager" echo " stop Stop Catalina" echo " stop -force Stop Catalina (followed by kill -KILL);" exit 1 fi 错误提示信息: 没有错误错误提示信息,只是我想改变tomcat的控制窗口的输出。 问题: 在linux下, tomcat服务器的控制窗口信息输出到catalina.out文件中, 但是随着时间的推移, 该文件会越来越大。所以在此情况下, 我不希望该一个文件很大, 我的想法: 该文件每天产生一个备份文件,然后一个星期定时清理一次。 你的分析: 分析如下: 在配置文件catalina.sh中有下面一段设置: elif [ "$1" = "start" ] ; then shift touch "$CATALINA_BASE"/logs/catalina.out if [ "$1" = "-security" ] ; then echo "Using Security Manager" shift "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -Djava.security.manager \ -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" start \ >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & if [ ! -z "$CATALINA_PID" ]; then echo $! > $CATALINA_PID fi else "$_RUNJAVA" $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -Dcatalina.base="$CATALINA_BASE" \ -Dcatalina.home="$CATALINA_HOME" \ -Djava.io.tmpdir="$CATALINA_TMPDIR" \ org.apache.catalina.startup.Bootstrap "$@" start \ >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & if [ ! -z "$CATALINA_PID" ]; then echo $! > $CATALINA_PID fi fi 该catalina.out文件中的内容是由于tomcat服务器的控制窗口中的信息重定向到该文件中去了。 我想请教一下:有什么方法可以该文件每天备份一个? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2005-08-23
该文件会自动每天产生一个备份,这个文件不会变大,每天都自动进行日志切换。你想要的功能Tomcat本身就具备了,真不知道你究竟有没有用过tomcat。
|
|
返回顶楼 | |
发表时间:2005-08-24
谢谢robbin的回复, 但是我还想请教一个问题:你说的catalina.out每天都会产生一个备份文件,自动切换, 那么备份的文件名是什么, 另外就是该备份文件的数目是不是持续增长下去,是不是就向log4j备份日志文件那样?
另外有一个问题, 我的tomcat的server.xml配置文件如下: <?xml version='1.0' encoding='utf-8'?> <Server port="18005"> <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/> <GlobalNamingResources> <Environment name="simpleValue" type="java.lang.Integer" value="30"/> <Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/> <ResourceParams name="UserDatabase"> <parameter> <name>factory</name> <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value> </parameter> <parameter> <name>pathname</name> <value>conf/tomcat-users.xml</value> </parameter> </ResourceParams> </GlobalNamingResources> <Service name="Catalina"> <Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="18080" redirectPort="18443" maxSpareThreads="512" maxThreads="1024" minSpareThreads="25"> </Connector> <Connector port="18009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="18443"> </Connector> <Engine name="Catalina"> <Host appBase="webapps" name="localhost"> <Logger className="org.apache.catalina.logger.FileLogger" suffix=".out" timestamp="true"/> </Host> <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/> <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/> </Engine> </Service> </Server> 同时在webapps文件夹中有root应用程序, 如果用户在浏览器中的地址栏输入“http://localhost:8080/" 就会出现tomcat的首页,但是现在我想出现我自己系统的首页,同时不能删除root应用程序, 不知道该怎么配置?还是要该tomcat的源代码? 但是最好不要改tomcat的源代码。 |
|
返回顶楼 | |
发表时间:2005-08-24
catalina.2005-08-22.log
catalina.2005-08-23.log catalina.out 按照日期每天一个日志文件。默认的日志文件不会进行周日志交换。日志可以在server.xml里面进行详细的配置,具体配置请参考Tomcat文档。 ROOT应用可以自己配置,配置一个Context,path=""就是ROOT应用,context配置请参考Tomcat文档。 |
|
返回顶楼 | |
发表时间:2005-08-25
tomcat的server.xml配置文件中的内容,其中我只抽出context片段内容,如下:
<Context ...> ... <Parameter name="companyName" value="My Company, Incorporated" override="false"/> ... <Environment name="maxExemptions" value="10" type="java.lang.Integer" override="false"/> ... <Resource name="jdbc/EmployeeDB" auth="Container" type="javax.sql.DataSource" description="Employees Database for HR Applications"/> ... <ResourceParams name="jdbc/EmployeeDB"> <parameter> <name>driverClassName</name> <value>org.hsql.jdbcDriver</value> </parameter> <parameter> <name>url</name> </value>jdbc:HypersonicSQL:database</value> </parameter> <parameter> <name>user</name> <value>dbusername</value> </parameter> <parameter> <name>password</name> <value>dbpassword</value> </parameter> </ResourceParams> ... <ResourceLink name="linkToGlobalResource" global="simpleValue" type="java.lang.Integer" ... </Context> 现在我想问几个问题: (1) 参数companyName是否只在启动该web应用的时候才有用, 去初始化web应用上下文?另外我想知道这些参数的值可不可以在写java类的时候通过调用某个类的某个方法来获取该参数的名称和值? 可不可以写几行代码来回复。 (2) Environment 这个我不知道其什么作用?是不是也向参数那样。 (3) Resource 是否可以通过JNDI的lookup来获取该资源?怎么样写法? (4) ResourceParams是不是也是就启动该web应用的时候来产生一个资源对象,然后程序代码就可以通过JNDI的lookup来获取该资源对象了。 (5) ResourceLink这个是资源连接, 是不是就是连接到server.xml文件中的全局资源中的某个对象? (6) 我想问一下: 在context中的定义的资源对象是否可以和全局资源中的资源对象同名?如果可以了的话是怎么样?如在该wen应用获取到的该资源对象是该web应用中所定义的还是全局中的资源对象? |
|
返回顶楼 | |
发表时间:2005-09-12
太多了把
|
|
返回顶楼 | |
发表时间:2005-09-12
发射点犯得上
|
|
返回顶楼 | |
发表时间:2005-09-12
wxz258 写道 发射点犯得上
好的发射点发射点 |
|
返回顶楼 | |
发表时间:2005-09-12
幸运之星 写道 tomcat的server.xml配置文件中的内容,其中我只抽出context片段内容,如下:
<Context ...> ... <Parameter name="companyName" value="My Company, Incorporated" override="false"/> ... <Environment name="maxExemptions" value="10" type="java.lang.Integer" override="false"/> ... <Resource name="jdbc/EmployeeDB" auth="Container" type="javax.sql.DataSource" description="Employees Database for HR Applications"/> ... <ResourceParams name="jdbc/EmployeeDB"> <parameter> <name>driverClassName</name> <value>org.hsql.jdbcDriver</value> </parameter> <parameter> <name>url</name> </value>jdbc:HypersonicSQL:database</value> </parameter> <parameter> <name>user</name> <value>dbusername</value> </parameter> <parameter> <name>password</name> <value>dbpassword</value> </parameter> </ResourceParams> ... <ResourceLink name="linkToGlobalResource" global="simpleValue" type="java.lang.Integer" ... </Context> 现在我想问几个问题: (1) 参数companyName是否只在启动该web应用的时候才有用, 去初始化web应用上下文?另外我想知道这些参数的值可不可以在写java类的时候通过调用某个类的某个方法来获取该参数的名称和值? 可不可以写几行代码来回复。 (2) Environment 这个我不知道其什么作用?是不是也向参数那样。 (3) Resource 是否可以通过JNDI的lookup来获取该资源?怎么样写法? (4) ResourceParams是不是也是就启动该web应用的时候来产生一个资源对象,然后程序代码就可以通过JNDI的lookup来获取该资源对象了。 (5) ResourceLink这个是资源连接, 是不是就是连接到server.xml文件中的全局资源中的某个对象? (6) 我想问一下: 在context中的定义的资源对象是否可以和全局资源中的资源对象同名?如果可以了的话是怎么样?如在该wen应用获取到的该资源对象是该web应用中所定义的还是全局中的资源对象? |
|
返回顶楼 | |
发表时间:2006-09-21
robbin 写道 catalina.2005-08-22.log
catalina.2005-08-23.log catalina.out 按照日期每天一个日志文件。默认的日志文件不会进行周日志交换。日志可以在server.xml里面进行详细的配置,具体配置请参考Tomcat文档。 ROOT应用可以自己配置,配置一个Context,path=""就是ROOT应用,context配置请参考Tomcat文档。 以前我遇到的情况也是和robbin说的一样,但是现在的项目和幸运之星说的一样,catalina.out每天都增加啊,并没有每日备份啊,现在配置是: log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n log4j.rootLogger=warn, stdout log4j.logger.org.hibernate=info log4j.logger.org.hibernate.SQL=info log4j.logger.com.bjde=debug log4j.logger.org.hibernate.type=info log4j.logger.org.hibernate.tool.hbm2ddl=debug <Context path="" docBase="/mis/web" debug="0" privileged="true"> <Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false"/> <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_mis_log." suffix=".txt" timestamp="true"/> </Context> 以前在配置文件有 log4j.appender.stdout.MaxFileSize=10MB 当写满10MB就会备份,不知道大家遇到同样的情况了吗 |
|
返回顶楼 | |