Linuxhttps.blog.chinaunix.net
viviecho
全部博文(279)
2013年(1)
2012年(39)
2011年(35)
2009年(29)
2008年(131)
2007年(44)
marsgray
abc123zx
lionking
cynthia
格伯纳
Bsolar
浪花小雨
danxingd
shibaola
快乐的小
小石匠_
linxuegu
分类:
2008-06-13 12:50:01
#!/usr/bin/perlrequire '/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;
上一篇:checkintegrity.sh (将ws1的表结构导出跟原有的结构文件比较)
下一篇:filecleanup30.pl(ftp下面的文件超过30天删除)
登录 注册