From 35e973999ff4a9a83e3c02dc32a0a859ad60d457 Mon Sep 17 00:00:00 2001 From: Urban Date: Sat, 18 Jul 2026 11:00:20 +0200 Subject: [PATCH] Document scheduled WCX updates --- README.md | 42 +++++++++++++++++++------- scripts/scheduled_update_wcx.sh | 53 +++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 10 deletions(-) create mode 100755 scripts/scheduled_update_wcx.sh diff --git a/README.md b/README.md index a2b20c9..a3cf380 100644 --- a/README.md +++ b/README.md @@ -761,15 +761,37 @@ Google Cloud Vision does not guarantee this exact structure. Unexpected output i OCR processing is currently started manually for one movie ID at a time. -## Planned next steps +## Scheduled updates -Potential next steps include: +WCX is updated automatically by a systemd timer. + +The timer runs every night around 03:30. The wrapper script only performs a +full update when at least approximately 48 hours have passed since the previous +successful scheduled run. + +Check the timer: + +```bash +systemctl list-timers wcx-update.timer +``` + +Follow the service log: +```bash +sudo journalctl -u wcx-update.service -f +``` +Show the latest service output: +```bash +sudo journalctl -u wcx-update.service -n 100 --no-pager +```` +Run the scheduled service manually: +```bash +sudo systemctl start wcx-update.service +``` +Check its status: +```bash +systemctl status wcx-update.service --no-pager +``` +The timestamp of the latest successful scheduled update is stored in: + +database/last_scheduled_update -* automatically process movies with `ocr_status = pending` -* add retry support for failed OCR requests -* provide commands for manually approving or correcting OCR results -* add database backup handling -* export the complete index to JSON or CSV -* add Emby-compatible metadata export -* schedule the scraper and import process -* create an orchestration script for the complete automated workflow diff --git a/scripts/scheduled_update_wcx.sh b/scripts/scheduled_update_wcx.sh new file mode 100755 index 0000000..a8c8592 --- /dev/null +++ b/scripts/scheduled_update_wcx.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# +# Run the WCX update at most once every 48 hours. +# +# The systemd timer invokes this script every night. The timestamp file is +# updated only after a successful WCX update. +# + +set -Eeuo pipefail + +ROOT_DIR="/storage/disk1/WCX" + +UPDATE_SCRIPT="${ROOT_DIR}/scripts/update_wcx.sh" +STAMP_FILE="${ROOT_DIR}/database/last_scheduled_update" + +MINIMUM_INTERVAL_SECONDS=$((47 * 60 * 60)) + + +log() { + printf '[%s] %s\n' \ + "$(date '+%Y-%m-%d %H:%M:%S')" \ + "$*" +} + + +if [[ ! -x "${UPDATE_SCRIPT}" ]]; then + log "ERROR: Update script is missing or not executable: ${UPDATE_SCRIPT}" >&2 + exit 1 +fi + + +if [[ -f "${STAMP_FILE}" ]]; then + current_time=$(date +%s) + previous_time=$(stat -c %Y "${STAMP_FILE}") + elapsed_seconds=$((current_time - previous_time)) + + if (( elapsed_seconds < MINIMUM_INTERVAL_SECONDS )); then + elapsed_hours=$((elapsed_seconds / 3600)) + + log "Skipping update; previous successful scheduled run was ${elapsed_hours} hours ago." + exit 0 + fi +fi + + +log "Starting scheduled WCX update." + +"${UPDATE_SCRIPT}" + +touch "${STAMP_FILE}" + +log "Scheduled WCX update completed successfully."