11 lines
308 B
Python
11 lines
308 B
Python
|
import subprocess
|
||
|
|
||
|
# 使用subprocess执行命令
|
||
|
result = subprocess.run(['sudo', 'systemctl', 'stop', 'django_app'], capture_output=True, text=True)
|
||
|
|
||
|
# 打印输出(如果有的话)
|
||
|
print(result.stdout)
|
||
|
|
||
|
# 检查是否有错误
|
||
|
if result.stderr:
|
||
|
print(f"Error: {result.stderr}")
|