https://www.jianshu.com/p/5d999a668e79 import subprocess print subprocess.call("service apache2 status", shell=True) import os print os.system("service apache2 status")