定时清理Redis数据
#!/usr/bin/python
#coding: utf-8
import datetime
import sys
import redis
from dingding_simple import warning
def getdate():
today = datetime.datetime.now() - datetime.timedelta(days=7)
re_date = (today).strftime('%Y_%m_%d')
print(re_date)
return re_date
def getConn(host, pwd, db, port):
conn = redis.Redis(host=host, port=port, password=pwd,db=db)
return conn
def to_del():
host = ''
pwd = ''
db = 0
port = 6379
redis_connect = getConn(host,pwd,db,port)
key = 'DEL MACHINE:TRIP_BEGIN:' + getdate();
print('删除的key' + key)
redis_connect.delete(key)
to_del()