import subprocess
import time

# === Configuration ===
php_path = r"C:\wamp64\bin\php\php8.3.14\php.exe"
project_path = r"C:\wamp64\www\alrahma_school_sunday"
command = f'"{php_path}" "{project_path}\\spark" users:delete-inactive-users'

# === Loop Settings ===
interval_seconds = 60 * 15  # Run every 5 minutes (change as needed)

while True:
    try:
        print("\n🕐 Running delete-inactive-users command...")
        subprocess.run(command, check=True, shell=True)
        print("✅ Command executed successfully.")
    except subprocess.CalledProcessError as e:
        print("❌ Failed to run the command.")
        print(e)

    print(f"⏳ Waiting {interval_seconds} seconds before next run...\n")
    time.sleep(interval_seconds)


    #/var/lib/vz/dump/vzdump-lxc-104-2025_05_27-02_51_09.tar.zst'