Scheduled Sync with Cron
Run WCP syncs automatically on a fixed schedule without manual intervention.
Option A: Cron
Section titled “Option A: Cron”Add an entry to your crontab:
crontab -eSync every 5 minutes:
*/5 * * * * curl -s -X POST http://localhost:8000/api/sync/run >> /var/log/wcp-cron.log 2>&1Sync once per hour:
0 * * * * curl -s -X POST http://localhost:8000/api/sync/run >> /var/log/wcp-cron.log 2>&1Option B: systemd Timer
Section titled “Option B: systemd Timer”Create /etc/systemd/system/wcp-sync.service:
[Unit]Description=WCP sync cycle
[Service]Type=oneshotExecStart=/usr/bin/curl -s -X POST http://localhost:8000/api/sync/runCreate /etc/systemd/system/wcp-sync.timer:
[Unit]Description=Run WCP sync every 5 minutes
[Timer]OnBootSec=1minOnUnitActiveSec=5min
[Install]WantedBy=timers.targetEnable:
sudo systemctl daemon-reloadsudo systemctl enable --now wcp-sync.timerMonitoring Scheduled Syncs
Section titled “Monitoring Scheduled Syncs”Check the last sync result:
curl http://localhost:8000/api/sync/statusView recent logs:
curl "http://localhost:8000/api/logs?limit=20"Check health:
curl http://localhost:8000/healthHandling Failures
Section titled “Handling Failures”If the WCP server is down when cron fires, the curl will fail silently. Add basic alerting:
*/5 * * * * curl -sf -X POST http://localhost:8000/api/sync/run || echo "WCP sync failed at $(date)" >> /var/log/wcp-errors.logOr monitor the health endpoint with an uptime checker (UptimeRobot, Hetrix, etc.).