Created
August 29, 2015 02:44
-
-
Save dotmanila/41f28a4ceb5838c531a4 to your computer and use it in GitHub Desktop.
Check create timestamp of binary logs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os, time | |
from struct import unpack | |
from datetime import datetime | |
d = '/home/mysql/backup_data/backup_str/binlogs' | |
x = 180 | |
oldest = int(time.time())-(90*24*60*60) | |
l = os.listdir(d) | |
l.sort() | |
for f in l: | |
b = open(os.path.join(d, f), 'rb') | |
if b.read(4) != '\xfebin': continue | |
b.seek(4) | |
ts = unpack('I', b.read(4))[0] | |
print "%s %s" % (str(f), str(datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'))) | |
#print "%s %d" % (f, ts) | |
b.close() | |
if ts >= oldest: | |
print "Reached our threshold, quitting\n" | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment