Files

SIRO Maps — Crontab & Scheduled Jobs Directory

دليل وجدولة المهام الدورية والتشغيل الآلي لمنصة سيرو

This directory contains the central crontab configuration, installer, and documentation for all scheduled background jobs running on the SIRO Maps server.


📋 Overview of Scheduled Jobs

# Task Name Schedule Script / Command Log File Description
1 Map, Place & OSM Gate Sync Every 10 days at 03:00 infrastructure/scripts/update-data.sh infrastructure/logs/update-data.log Updates the configured regional OSM PBF, rebuilds routing data, refreshes regional place names, imports only explicitly tagged OSM entrance/gate nodes, then clears search cache.
2 Supplemental Place Enrichment Every 1st & 15th at 07:00 scripts/master_cron_sync.sh logs/cron_places_sync.log Enriches Iraq and Egypt place tables. Gate coordinates are no longer generated by this job.
3 Daily Database Backup Daily at 02:00 scripts/backup_db.sh logs/cron_backup.log Backs up custom tables and the unverified legacy-gates archive with 7-day retention.
4 Weekly DB Vacuum & Analyze Every Sunday at 04:00 docker compose exec db vacuumdb logs/cron_vacuum.log Reclaims space and updates PostgreSQL query planner statistics for fast spatial and trigram GIN queries.
5 Weekly Maintenance & Log Rotation Every Sunday at 05:00 scripts/cleanup_logs.sh logs/cron_cleanup.log Truncates logs exceeding 50MB, deletes logs older than 14 days, and prunes dangling Docker images.

🚀 Quick Setup on Any Server / Migration Guide

When setting up a new server or migrating the platform:

# 1. Navigate to the app directory
cd /home/hamzadoctor/app

# 2. Run the Crontab Installer
bash crontab/install_cron.sh

The installer will automatically:

  1. Create required directories (logs/ and backups/db/).
  2. Make all scripts in scripts/ executable (chmod +x).
  3. Load all jobs from crontab/crontab.txt into the server's crontab.

🔍 How to Monitor & Inspect Logs

# View active crontab entries
crontab -l

# Watch live output of map, place, and gate sync
tail -f /home/hamzadoctor/app/infrastructure/logs/update-data.log

# Check recent database backups
ls -lh /home/hamzadoctor/app/backups/db/

# Check road network update log
tail -n 100 /home/hamzadoctor/app/logs/cron_osm_update.log

⚡ Manual Execution (Testing)

You can manually trigger any of these jobs at any time without waiting for the cron schedule:

# Run the 10-day map, places, and source-backed gate sync
/bin/bash /home/hamzadoctor/app/infrastructure/scripts/update-data.sh

# Run Database Backup
/bin/bash /home/hamzadoctor/app/scripts/backup_db.sh

# Run Log & Docker Maintenance
/bin/bash /home/hamzadoctor/app/scripts/cleanup_logs.sh