ps | grep 検索でgrep自体のプロセスを表示させ無い方法
コマンドに入力する場合は、以下。
ps aux | grep [h]ttp
Python Fabricの中で使ったコードの一部は、以下。
sudo('apachectl -k graceful-stop') is_apache_stopped = False cnt = 0 SLEEP_SEC = 10 MAX_CNT = 30 # 300秒でタイムアウト while is_apache_stopped == False: with settings(warn_only=True): res = run('ps aux | grep [h]ttp') if res == "" or res is None: run("echo 'ps aux returns nothing(httpd stopped)'") is_apache_stopped = True else: time.sleep(SLEEP_SEC) cnt += 1 if cnt > MAX_CNT: # timeout run("echo 'httpd stop graceful time out.'") return