diff --git a/scripts/nas_sync/sync_parquet.sh b/scripts/nas_sync/sync_parquet.sh index 9fc4c17..0c875c2 100644 --- a/scripts/nas_sync/sync_parquet.sh +++ b/scripts/nas_sync/sync_parquet.sh @@ -8,6 +8,19 @@ VPS=Administrator@49.232.102.198 DATA=/volume1/stock/sanguo_vnpy_v2/data LOG=/volume1/stock/sanguo_vnpy_v2/data_backup/parquet.log +# 互斥锁(2026-08-21): 触发源两路=周日钩子(sync_valuation_daily.sh)与 DSM id=6 周日04:00, +# 双 scp -r 并发写同文件会撕损; mkdir 原子锁, >6h 视陈旧覆盖(单跑 70min 远不到)。 +LOCK=/volume1/stock/sanguo_vnpy_v2/data_backup/parquet_full.lock +if [ -d "$LOCK" ]; then + if [ -z "$(find "$LOCK" -maxdepth 0 -mmin +360 2>/dev/null)" ]; then + echo "[$(date '+%T')] lock held, another full sync running -> skip" >> "$LOG" + exit 0 + fi + rmdir "$LOCK" 2>/dev/null +fi +mkdir "$LOCK" 2>/dev/null || { echo "[$(date '+%T')] lock mkdir fail" >> "$LOG"; exit 1; } +trap 'rmdir "$LOCK" 2>/dev/null' EXIT + echo "=== parquet scp start $(date) ===" >> "$LOG" cd "$DATA" || { echo "cd fail" >> "$LOG"; exit 1; }