1、主要是导入redis模块,如果不存在则执行pip install redis 安装。

#!/usr/bin/env python
import redis
import time
ip='10.12.41.16'
password='Tvgpg#cdz'
r=redis.Redis(host=ip,password=password,port=16379,db=0)
while True:
  localtime = time.asctime( time.localtime(time.time()) )
  start_time = time.time()
  res=r.get('k1')
  end_time = time.time()
  time.sleep(5)
  running_time = end_time - start_time
  print("keys:%s running_time : %.5f sec localtime:%s" %(res,running_time,localtime))

2、放到后台运行并写入文件

[root@db redis_monitor]# nohup  -u check_python.py >redis_out.txt &

  

相关文章:

  • 2022-12-23
  • 2021-05-08
  • 2022-12-23
  • 2021-04-13
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
猜你喜欢
  • 2022-12-23
  • 2021-08-19
  • 2021-07-02
  • 2021-06-11
  • 2021-12-12
相关资源
相似解决方案