25 lines
874 B
Python
25 lines
874 B
Python
import time
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
|
|
def run_audit():
|
|
print(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] Starting Email Audit...")
|
|
try:
|
|
# Run the actual export script
|
|
result = subprocess.run([sys.executable, "export_emails_v2.py"], check=True)
|
|
print(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] Audit finished with exit code {result.returncode}")
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] Audit failed: {e}")
|
|
except Exception as e:
|
|
print(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] Unexpected error: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
# Initial run on startup
|
|
run_audit()
|
|
|
|
# Loop every 12 hours
|
|
while True:
|
|
print(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] Waiting 12 hours for next run...")
|
|
time.sleep(12 * 3600)
|
|
run_audit()
|