Chinaunix首页 | 论坛 | 博客
  • 博客访问: 468372
  • 博文数量: 279
  • 博客积分: 4467
  • 博客等级: 上校
  • 技术积分: 2830
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-03 14:43
文章分类

全部博文(279)

文章存档

2013年(1)

2012年(39)

2011年(35)

2009年(29)

2008年(131)

2007年(44)

分类:

2008-06-13 12:50:01


#!/usr/bin/perl

require '/opt/ws1/run_control.pl';
#$srcdatabase='ws1';

#$localdbhost='127.0.0.1';

#$localdbuser='ws1';

#$localdbpass='123ws1';

#$srctable='inbound_xf_toposcostadjh';

my $stagedbh=DBI->connect("DBI:mysql:database=$localdatabase;host=$localdbhost","$localdbuser","$localdbpass",{'RaiseError'=>1, 'AutoCommit' => 0}) or die "cannot connect!\n";
$stagedbh->do("SET NAMES 'utf8'");
open TABLE,"$ws2/create_time.txt"or die "can't open create_time.txt:!\n";
foreach $srctable(<TABLE>)
{
$sth=$stagedbh->prepare(qq/select create_time from $srctable/);
$sth->execute();
@date=localtime();
$cyear="20".substr($date[5],1,2);
$cmon=sprintf("%02d",$date[4]+1);
$cday=sprintf("%02d",$date[3]);
$string1=join "-",$cyear,$cmon,$cday;
#print "string1:$string1\n";

print "tablename:$srctable\n\n";
while ($create_time=$sth->fetchrow_array){
$date1=ParseDate($string1);
$date2=ParseDate($create_time);
#print "date1:$date1\n";

#print "date2:$date2\n";

$delta=DateCalc($date1,$date2,\$err);
@count=split /:/,$delta;
$count=$count[2]*7+$count[3];
print "create_time:$create_time\n";
print "days:$count\n";
if($count>=30){
print "record deleted\n\n";
#$stagedbh->do(qq/delete from $srctable where create_time=$create_time/);

}
}
}
$sth->finish();
$stagedbh->disconnect();
close TABLE;

阅读(162) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~