1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 # author:lipc
4
5 import os,time
6 process_name = ["mysql","redis"]
7 for i in process_name:
8 try:
9 process = len(os.popen('ps aux | grep "' + i + '" | grep -v grep | grep -v tail').readlines())
10 if process >= 1:
11 print("True")
12 else:
13 print("False")
14 f = open('/app/20200423.log', "a")
15 f.write('[' + str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())) + '] no redis service,start it!\n')
16 f.close()
17 time.sleep(3)
18 os.system('cd /app/redis/bin/ && ./start.sh')
19 except:
20 print("Check process ERROR!!!")