Created
September 18, 2017 03:20
-
-
Save XUJiahua/48bdc8687500958733aa4c3049c831cd to your computer and use it in GitHub Desktop.
ElasticSearch数据清理(保留90天)
This file contains 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
from datetime import datetime | |
from time import mktime | |
import time | |
import sys | |
for line in sys.stdin: | |
try: | |
datestr =line.strip()[-10:] | |
dt = time.strptime(datestr, "%Y.%m.%d") | |
dt = datetime.fromtimestamp(mktime(dt)) | |
if (datetime.now() - dt).days > 90: | |
print line.strip() | |
except: | |
x = 1 |
This file contains 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
#!/bin/bash | |
curl http://10.171.255.144:9200/_cat/indices | awk '{print $3 }' | python filter_log_before_3_month.py | awk '{print "-X DELETE http://10.171.255.144:9200/"$0}' | xargs curl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment