demo.py 587 B

123456789101112131415161718192021222324
  1. # -*- coding: utf-8 -*-
  2. # @Author: wangkun
  3. # @Time: 2023/5/23
  4. import os
  5. import psutil
  6. class Demo:
  7. @classmethod
  8. def demo1(cls):
  9. # cmd = "ps aux | grep Appium.app"
  10. cmd = 'ps -ef | grep "run_gongzhonghao1_author_scheduling.py" | grep -v "grep"'
  11. result = os.popen(cmd).read()
  12. print(len(result))
  13. if len(result) == 0:
  14. print("yes")
  15. # for process in psutil.process_iter():
  16. # # if "shipinhao" in process.name():
  17. # print(f"{process.pid}, {process.name()}")
  18. if __name__ == "__main__":
  19. Demo.demo1()