win 系统设置weblogic 进行定时自动重启并删除其日志和缓存文件,定时监控cpu是否达到100%并重启weblogic服务

时间:2024-03-07 14:32:45


一:如何在win系统设置 任务管理:请百度查询 win系统设置 任务管理

  image

0FQGG@GY_9$@IJ$_GC]~AV7

二:设置 webogic 重启并删除垃圾文件的bat脚本

sqlplus  /nolog   	@C:\Users\Administrator\Desktop\drop_trigger.sql



SETLOCAL

set stop_DOMAIN_HOME=E:\Weblogic_dimians\domains\base_domain\bin

call "%stop_DOMAIN_HOME%\stopWebLogic.cmd" %*

ENDLOCAL

@rmdir /s/q E:\Weblogic_dimians\domains\base_domain\servers\AdminServer\logs  目录下的所有日志文件信息
del E:\Weblogic_dimians\domains\base_domain\servers\AdminServer\logs2\*.* /s /q
del E:\Weblogic_dimians\domains\base_domain\servers\AdminServer\cache\*.* /s /q
del E:\Weblogic_dimians\domains\base_domain\servers\AdminServer\data\*.* /s /q
del E:\Weblogic_dimians\domains\base_domain\servers\AdminServer\tmp\*.* /s /q
del C:\Users\Administrator\AppData\Local\Temp\datamodel\*.* /s /q
copy C:\Users\Administrator\Desktop\log4j.properties  E:\Weblogic_dimians\domains\base_domain\war\yth\WEB-INF\classes\log4j.properties
copy  C:\Users\Administrator\Desktop\licences_lib\pwp-core-2.0.1.20161101.20.jar   E:\Weblogic_dimians\domains\base_domain\war\yth\WEB-INF\lib\pwp-core-2.0.1.20161101.20.jar
copy  C:\Users\Administrator\Desktop\licences_lib\pwp-framework-3.1.0.20171114.11.release.jar  E:\Weblogic_dimians\domains\base_domain\war\yth\WEB-INF\lib\pwp-framework-3.1.0.20171114.11.release.jar
copy  C:\Users\Administrator\Desktop\licences_lib\gdsd-czjd-0.0.1-SNAPSHOT.jar  E:\Weblogic_dimians\domains\base_domain\war\yth\WEB-INF\lib\gdsd-czjd-0.0.1-SNAPSHOT.jar


SETLOCAL

set DOMAIN_HOME=E:\Weblogic_dimians\domains\base_domain

call "%DOMAIN_HOME%\bin\startWebLogic.cmd" %*

ENDLOCAL

drop_trigger.sql

conn SYNC_PLUS_1/SYNC_PLUS_1@192.168.1.168/pdborcl ;


 truncate table pwp_licence;

 quit;

log4j配置

################ levl:DEBUG < INFO< WARN< ERROR<FATAL ; OFF/ ALL
log4j.rootLogger =    CONSOLE ,logFile ,INFO  , ERROR  ,FATAL  ,  WARN

dir = servers/AdminServer/logs/pwp-log

# the dir of the tomcat input log
# dir = ${catalina.home}

# Set hibernate\'s log level to Info begin  
log4j.logger.org.hibernate=WARN
# log4j.logger.net.sf.hibernate=INFO
log4j.logger.net.sf=WARN
# Set hibernate\'s log level to Info end
log4j.logger.org.jbpm=WARN
log4j.logger.org.quartz=WARN


log4j.logger.org.hibernate.SQL=INFO
log4j.logger.org.apache.commons.beanutils.ConvertUtils=INFO
log4j.additivity.org.apache.commons.beanutils.ConvertUtils=false

log4j.logger.org.apache.commons.beanutils.BeanUtils=INFO
log4j.additivity.org.apache.commons.beanutils.BeanUtils=false

log4j.logger.org.apache = WARN
#log4j.logger.org.apache.tomcat.util = INFO
#log4j.logger.org.apache.commons = INFO
#log4j.logger.org.apache.catalina = INFO
#log4j.additivity.org.apache.tomcat.util = false
#log4j.additivity.org.apache.commons = false
log4j.logger.org.springframework=WARN
#

#CONSOLE
#org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold = DEBUG
log4j.appender.console.ImmediateFlush=true
#System.out
log4j.appender.CONSOLE.Target = System.err
log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c - %m%n
#
# \u65E5\u5FD7\u6587\u4EF6(logFile) 
log4j.appender.logFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logFile.Threshold=DEBUG
log4j.appender.logFile.ImmediateFlush=true
log4j.appender.logFile.Append=true
log4j.appender.logFile.File= ${dir}/logFile.log
log4j.appender.logFile.DatePattern =\'.\'yyyy-MM-dd-HH-mm\'.log\'
log4j.appender.logFile.layout=org.apache.log4j.PatternLayout
log4j.appender.logFile.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l\: %m %x %n
#

#INFO
log4j.logger.com.alexgaoyh.util.INFO=INFO
log4j.appender.INFO = org.apache.log4j.DailyRollingFileAppender
log4j.appender.INFO.layout = org.apache.log4j.PatternLayout
log4j.appender.INFO.layout.ConversionPattern = "%p %d{yyyy-MM-dd HH:mm:ss} %-50.50c(%L) - %m%n
log4j.appender.INFO.File = ${dir}/INFO.log
log4j.appender.INFO.DatePattern =\'.\'yyyy-MM-dd-HH\'.log\'
log4j.appender.INFO.Append = true
log4j.appender.INFO.Threshold = INFO

#

#ERROR
log4j.appender.ERROR = org.apache.log4j.DailyRollingFileAppender
log4j.appender.ERROR.Threshold = ERROR
log4j.appender.ERROR.File = ${dir}/ERROR.log
log4j.appender.ERROR.DatePattern =\'.\'yyyy-MM-dd-HH\'.log\'
log4j.appender.ERROR.Append = true
log4j.appender.ERROR.layout = org.apache.log4j.PatternLayout
log4j.appender.ERROR.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %5p %c:%t - %m%n
#

#FATAL
log4j.appender.FATAL = org.apache.log4j.DailyRollingFileAppender
log4j.appender.FATAL.File = ${dir}/FATAL.log
log4j.appender.FATAL.DatePattern =\'.\'yyyy-MM-dd-HH\'.log\'
log4j.appender.FATAL.Append = true
log4j.appender.FATAL.Threshold = FATAL
log4j.appender.FATAL.layout = org.apache.log4j.PatternLayout
log4j.appender.FATAL.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %5p %c:%t - %m%n
#

#WARN
log4j.appender.WARN = org.apache.log4j.DailyRollingFileAppender
log4j.appender.WARN.File = ${dir}/WARN.log
log4j.appender.WARN.DatePattern =\'.\'yyyy-MM-dd-HH\'.log\'
log4j.appender.WARN.Append = true
log4j.appender.WARN.Threshold = WARN
log4j.appender.WARN.layout = org.apache.log4j.PatternLayout
log4j.appender.WARN.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %5p %c:%t - %m%n
#







delete_log.bat

del E:\Weblogic_dimians\domains\base_domain\servers\AdminServer\logs\pwp-log\logFile.log.*.* /s /q
del E:\Weblogic_dimians\domains\base_domain\servers\AdminServer\logs\pwp-log\ERROR.log.*.*  /s /q
del E:\Weblogic_dimians\domains\base_domain\servers\AdminServer\logs\pwp-log\FATAL.log.*.*  /s /q
del E:\Weblogic_dimians\domains\base_domain\servers\AdminServer\logs\pwp-log\INFO.log.*.*  /s /q
del E:\Weblogic_dimians\domains\base_domain\servers\AdminServer\logs\pwp-log\WARN.log.*.*   /s /q





A)MP]T$_28VGZ6~184E8~4B



三:监测cpu是否100%,一旦100% 则重启weblogic 的bat

@echo off
for /f "tokens=2 delims==" %%a in (\'wmic path Win32_PerfFormattedData_PerfOS_Processor get PercentProcessorTime /value^|findstr "PercentProcessorTime"\') do (
set UseCPU=%%a
)
echo 111 CPU使用率:%UseCPU%%%
SETLOCAL

set stop_DOMAIN_HOME=C:\Users\Administrator\Desktop

if  %UseCPU% ==100  call "%stop_DOMAIN_HOME%\reload_yth_7001.bat" %*

ENDLOCAL

if  %UseCPU% !=100     exit;


ABTED0FR7IF8G9NSXAQ]YJP