Files
scud_ai/scripts/cron/run_reports_only.sh

23 lines
894 B
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
set -e
PROJECT_DIR="/home/apushkov/projects/scud_ai"
LOG_DIR="${PROJECT_DIR}/logs"
TODAY=$(date '+%Y-%m-%d')
LOG_FILE="${LOG_DIR}/cron_reports_${TODAY}.log"
ERR_LOG="${LOG_DIR}/cron_errors.log"
cd "${PROJECT_DIR}"
mkdir -p "${LOG_DIR}"
echo "==================================================" >> "${LOG_FILE}"
echo "[CRON REPORTS START] $(date '+%Y-%m-%d %H:%M:%S')" >> "${LOG_FILE}"
# Строго с --skip-export: расчет идет по последнему готовому снапшоту из SQLite
if "${PROJECT_DIR}/venv/bin/python" "${PROJECT_DIR}/main_etl.py" --skip-export >> "${LOG_FILE}" 2> >(tee -a "${ERR_LOG}" >> "${LOG_FILE}"); then
echo "[CRON REPORTS FINISH - SUCCESS] $(date '+%Y-%m-%d %H:%M:%S')" >> "${LOG_FILE}"
else
EXIT_CODE=$?
echo "[CRON REPORTS ERROR] Код ошибки: ${EXIT_CODE}" >> "${LOG_FILE}"
fi
echo "" >> "${LOG_FILE}"