#!/usr/bin/env python3 import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False) cmd = r""" cd /opt/douyinWEB/backend timeout 45 ./.venv/bin/python - <<'PY' from app import db db.update_settings_map({"covers_s3_keep_days": 2}) print("covers_s3_keep_days=", db.get_settings_map().get("covers_s3_keep_days")) PY systemctl restart douyinweb-api sleep 3 echo api=$(systemctl is-active douyinweb-api) df -h / | awk 'NR==2{print}' """ _i, o, e = c.exec_command(cmd, timeout=120) print(o.read().decode("utf-8", "replace")) err = e.read().decode("utf-8", "replace") if err.strip(): print("[stderr]", err[:1000]) c.close()