Bat Files - Yash-777/LearnJava GitHub Wiki
@echo off
REM @echo off means avoids commented info displaying in console.
REM set "var=value"
set "CATALINA_HOME=D:\Yashwanth\D Drive\Apache\apache-tomcat-7.0.37"
echo %CATALINA_HOME%Tomcat bin « catalina.bat
rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
set "%CATALINA_HOME%" == "D:\Yashwanth\D Drive\Apache\apache-tomcat-7.0.37"
rem ...
rem Ensure that any user defined CLASSPATH variables are not used on startup,
rem but allow them to be specified in setenv.bat, in rare case when it is needed.
set CLASSPATH=
rem Get standard environment variables
if not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHome
call "%CATALINA_BASE%\bin\setenv.bat"
goto setenvDone
:checkSetenvHome
if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat"
:setenvDone« setenv.bat
set CATALINA_HOME = "D:\Yashwanth\D Drive\Apache\apache-tomcat-7.0.37"
set "JRE_HOME=%ProgramFiles%\Java\jdk1.6.0_45\jre"
set "JAVA_HOME=%ProgramFiles%\Java\jdk1.6.0_45"Lock Screen
rundll32.exe user32.dll,LockWorkStationShutdown System
REM echo 1= 1 min
shutdown -s -t 0Temp, Pre-fetch Clean
@echo off
del /s /f /q c:\windows\temp\*.*
rd /s /q c:\windows\temp
md c:\windows\temp
del /s /f /q C:\WINDOWS\Prefetch
del /s /f /q %temp%\*.*
rd /s /q %temp%
md %temp%
deltree /y c:\windows\tempor~1
deltree /y c:\windows\temp
deltree /y c:\windows\Prefetch
deltree /y c:\windows\tmp
deltree /y c:\windows\ff*.tmp
deltree /y c:\windows\history
deltree /y c:\windows\cookies
deltree /y c:\windows\recent
deltree /y c:\windows\spool\printers
del c:\WIN386.SWP
clsCustom Batch file of Server start/status/stop
#!/bin/bash
# chkconfig: 234 20 80
# description: Tomcat Server basic start/shutdown script
# processname: tomcat
#
RUNAS=admin
export JAVA_HOME=/usr/local/jdk
export TOMCAT_HOME=/opt/tomcat
export ORIENTDB_HOME=/apps/orientdb
export MLM_CONFIG_HOME=/apps/config/myapp
#export JAVA_OPTS="$JAVA_OPTS -agentlib:TakipiAgent -Xmx128m -XX:+UseConcMarkSweepGC"
export JAVA_OPTS="$JAVA_OPTS $JSSE_OPTS -Dlogging.config=/apps/config/myapp/log4j2.xml"
export JAVA_OPTS="$JAVA_OPTS -Djna.nosys=true -DdefaultCharset=UTF-8 -Dfile.Encoding=UTF-8"
#export JAVA_OPTS="$JAVA_OPTS $JSSE_OPTS -DORIENTDB_NODE_NAME=runner1 -Dlogging.config=/apps/config/myapp/log4j2.xml -Ddistributed=true"
#export JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Xms2048m -Xmx4096m -XX:MaxDirectMemorySize=512g"
#export JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Xms8192m -Xmx30720m -XX:MaxDirectMemorySize=512g"
#export JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Xms8192m -Xmx16384m -Dstorage.diskCache.bufferSize=14000 -XX:MaxDirectMemorySize=512g"
#export JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Xms8192m -Xmx14384m -Dstorage.diskCache.bufferSize=56000 -XX:MaxDirectMemorySize=512g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/apps/heapdump/ -Dnetwork.http.sessionExpireTimeout=7200 -Dmail.smtp.ssl.protocols=TLSv1.2 -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.rmi.port=9011 -Djava.rmi.server.hostname=localhost"
export JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Xms8192m -Xmx14384m -Dstorage.diskCache.bufferSize=12000 -XX:MaxDirectMemorySize=512g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/apps/heapdump/ -Dnetwork.http.sessionExpireTimeout=7200 -Dmail.smtp.ssl.protocols=TLSv1.2"
#export distributed=true
START_TOMCAT=${TOMCAT_HOME}/bin/startup.sh
STOP_TOMCAT=${TOMCAT_HOME}/bin/shutdown.sh
#Tomacat-Start Command
start() {
echo `date`
echo -n "Starting tomcat: "
cd $TOMCAT_HOME
if [ `whoami` == "root" ]
then
/sbin/runuser -l ${RUNAS} -c ${START_TOMCAT}
else
${START_TOMCAT}
fi
status
}
#Tomacat-Status Command
status() {
pid=`ps aux | grep -w "tomcat"|grep -w "java" | grep -v grep | awk '{print $2}'`
if [ "$pid" == "" ]
then
echo "Tomcat is not running"
export stat=1
else
numthread=`ps -efL|grep $pid|grep -v grep|wc -l`
echo "Tomcat running on $pid...with $numthread threads"
export stat=0
fi
}
#Tomacat-Stop Command
stop() {
echo `date`
status
if [ $stat -ne 0 ]
then
echo -n
fi
echo -n "Shutting down tomcat: "
cd $TOMCAT_HOME
if [ `whoami` == "root" ]
then
/sbin/runuser -l ${RUNAS} -c ${STOP_TOMCAT}
else
${STOP_TOMCAT}
fi
echo "Waiting 40 seconds..."
waited=0
while [ $waited -le 40 ]
do
sleep 5
status
if [ $stat -eq 0 ]
then
waited=$((waited+5))
echo Waited $waited seconds...
else
waited=45
fi
done
if [ $waited -gt 40 ]
then
kill -9 $pid 2> /dev/null
fi
echo "done."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
exit 0