Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在linux中,如何使用python来检查外部的非系统程序是否正在运行?这个任务有标准模块吗?
使用psutil,例如
import psutil def check_if_running(name): for ps in psutil.process_iter(): if ps.name == name: return True return False check_if_running('python') >>> True
您可能对psutil感兴趣。否则,您可以使用子进程库调用pgrep 。