feat(shell-sync): run_cron_scheduler
This commit is contained in:
1 parent
c1d426040e
commit
70da49e95c
1 file changed
+24
@@ -336,3 +336,27 @@ start_heartbeat() {
|
||||
HEARTBEAT_PID=$!
|
||||
}
|
||||
|
||||
run_cron_scheduler() {
|
||||
local wrapper="${PID_DIR}/cron-sync-all.sh"
|
||||
local crontab_file="${PID_DIR}/sync.crontab"
|
||||
|
||||
# Cron starts commands with a minimal environment. Preserve this container's
|
||||
# configuration in a root-only Bash wrapper so arbitrary ACCOUNT_N_* values work.
|
||||
{
|
||||
printf '#!/bin/bash\n'
|
||||
export -p
|
||||
printf 'exec /sync.sh sync-all\n'
|
||||
} > "$wrapper"
|
||||
chmod 700 "$wrapper"
|
||||
printf '%s %s >> /proc/1/fd/1 2>&1\n' "$SYNC_CRON" "$wrapper" > "$crontab_file"
|
||||
|
||||
if ! crontab "$crontab_file"; then
|
||||
log "Configuration error: SYNC_CRON is not a valid cron expression: $SYNC_CRON"
|
||||
return 1
|
||||
fi
|
||||
log "Starting cron schedule: $SYNC_CRON"
|
||||
cron -f &
|
||||
CRON_PID=$!
|
||||
wait "$CRON_PID"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user