#!/bin/bash
# [2026-10-20] backup start for the one-off situations test (a one-off cron job did not fire on 10/13)
cd /var/www/screener/trade/reports/playbook
if pgrep -f "python3 situations_test.py" >/dev/null || grep -q SITUATIONS_DONE situations_test.log 2>/dev/null; then
  echo "$(date) guard: already running or done" >> situations_guard.log
else
  echo "$(date) guard: NOT running -> starting" >> situations_guard.log
  /usr/bin/flock -n /tmp/situations.lock nice -n 10 /usr/bin/python3 situations_test.py > situations_test.log 2>&1
fi
