标签:spl import 后台运行 imp oca monit start moni int
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 &
标签:spl import 后台运行 imp oca monit start moni int
原文地址:https://www.cnblogs.com/Dev0ps/p/12815286.html