ITPub博客

首页 > 数据库 > Oracle > 清理日志 scripts

清理日志 scripts

原创 Oracle 作者:beatony 时间:2014-06-20 17:10:44 0 删除 编辑

[root@YXT-016 pts]# mkdir /data/log_bak
[root@YXT-016 pts]# chown -R yxtuser. /data/log_bak/
 脚本内容如下:
 [yxtuser@YXT-016 scripts]$
cat log_dlpt.sh
#!/bin/sh
#scripts for backup tomcat logfile
#last modify at 2014/06/17
######set values######
yestoday=`date -d "1 days ago" +%Y-%m-%d`
bak_dir=/data/lg_bak/  
 
########function cp log file #####
function cp_log
{
cp $log_file $bakfile
 }

########function empty log file####
 function empty_log
{
echo > $log_file
}

###function gzip logfile ####
function gzip_logfile
{
if [ -f $bakfile ];
then gzip $bakfile else exit
fi
 }

####bakup jsonServer log###
baklog_dir=/data/log_bak/dlpt/jsonServer
log_file=/opt/yxt/dlpt/jsonServer/logs/catalina.out
bakfile=$baklog_dir/catalina.out.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log

####bakup smsService log ####
baklog_dir=/data/log_bak/dlpt/smsService
log_file=/opt/yxt/dlpt/smsService/logs/catalina.out
bakfile=$baklog_dir/catalina.out.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log


###bakup wap log###
baklog_dir=/data/log_bak/dlpt/wap
log_file=/opt/yxt/dlpt/wap/logs/catalina.out
bakfile=$baklog_dir/catalina.out.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log


###bakup wap log###
baklog_dir=/data/log_bak/dlpt/wm
log_file=/opt/yxt/dlpt/wm/logs/audit/auditIM.log
bakfile=$baklog_dir/auditIM.log.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log

###bakup wap log###
baklog_dir=/data/log_bak/dlpt/wm
log_file=/opt/yxt/dlpt/wm/logs/proxool/proxool.log
bakfile=$baklog_dir/proxool.log.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log

###bakup ps log###
baklog_dir=/data/log_bak/dlpt/ps
log_file=/opt/yxt/dlpt/ps/logs/catalina.out
bakfile=$baklog_dir/catalina.out.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log

###bakup ep-web log###
baklog_dir=/data/log_bak/dlpt/ep-web
log_file=/opt/yxt/dlpt/ep-web/logs/catalina.out
bakfile=$baklog_dir/catalina.out.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log


####bakup PC log###
baklog_dir=/data/log_bak/dlpt/PC
log_file=/opt/yxt/dlpt/PC/logs/catalina.out
bakfile=$baklog_dir/catalina.out.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log

###bakup op log###
baklog_dir=/data/log_bak/dlpt/op
log_file=/opt/yxt/dlpt/op/logs/catalina.out
bakfile=$baklog_dir/catalina.out.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log

###bakup sms log#####
baklog_dir=/data/log_bak/dlpt/sms
log_file=/opt/yxt/dlpt/sms/logs/catalina.out
bakfile=$baklog_dir/catalina.out.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log

###bakup crontabsend log###
baklog_dir=/data/log_bak/dlpt/crontabsend
log_file=/opt/yxt/dlpt/crontabsend/sendlogs/logs.log
bakfile=$baklog_dir/logs.log.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log

###bakup parseRecord log####
baklog_dir=/data/log_bak/dlpt/parseRecord
log_file=/opt/yxt/dlpt/parseRecord/logs/count.log
bakfile=$baklog_dir/count.log.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log

####bakup nginx log####
baklog_dir=/data/log_bak/nginx
log_file=/data/var/log/nginx/access.log
bakfile=$baklog_dir/access.log.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log

###bakup nginx log###
baklog_dir=/data/log_bak/nginx
log_file=/data/var/log/nginx/error.log
bakfile=$baklog_dir/error.log.$yestoday
mkdir -p $baklog_dir
cp_log
gzip_logfile
empty_log

###drop 30 days ago file ###
find $bak_dir -name "*.gz" -mtime 365 -exec rm -f {} \;

 ++++++++++++++++++++++++++
[yxtuser@szyxtapvm1 nginx]$ crontab -l
*/1 * * * * sh /opt/yxt/dlpt/parseRecord/startup_debug.sh > /dev/null 2>&1
*/5 * * * * sh /opt/yxt/dlpt/crontabsend/bookSend.sh > /dev/null 2>&1
0 2 * * * sh /home/yxtuser/scripts/log_dlpt.sh > /dev/null 2>&1 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22578826/viewspace-1190156/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2010-05-18

  • 博文量
    192
  • 访问量
    456143