# Scheduled / Cron Jobs

## Important
These notes record the known RBE scheduled jobs from the former operating environment. They are references, not an instruction to use the former MY.TOWN server paths. RBE's developer must substitute the actual PHP binary, application root and log paths in the new environment.

## Known production schedules
The former environment used the following RBE-related schedules:

### 1. IAMMETER standard reading sync
Former frequency:
- every 30 minutes

Application script:
- `application/v1/sync_from_cloud.php`

The former host invoked this through an external shell wrapper. In the new environment the developer may invoke the PHP script directly or implement an equivalent wrapper/retry mechanism.

Example pattern:
```cron
*/30 * * * * /usr/bin/php /PATH_TO_RBE_V1/sync_from_cloud.php >> /PATH_TO_LOG/rbe_iammeter_sync.log 2>&1
```

### 2. IAMMETER KVA sync
Former frequency:
- every 5 minutes

Application script:
- `application/v1/kva.php`

The former host invoked this through an external shell wrapper. The original wrapper retried a failed execution after a short delay. RBE's developer may reproduce equivalent retry handling if required.

Example pattern:
```cron
*/5 * * * * /usr/bin/php /PATH_TO_RBE_V1/kva.php >> /PATH_TO_LOG/rbe_kva.log 2>&1
```

### 3. Flecto electric sync
Former frequency:
- minute 6 and minute 36 of every hour

Application script:
- `application/v1/cron/flecto_electric_sync.php`

Example pattern:
```cron
6,36 * * * * /usr/bin/php /PATH_TO_RBE_V1/cron/flecto_electric_sync.php >> /PATH_TO_LOG/rbe_flecto_electric.log 2>&1
```

### 4. Flecto water sync
Former frequency:
- every 30 minutes

Application script:
- `application/v1/cron/water_meter_sync.php`

Example pattern:
```cron
*/30 * * * * /usr/bin/php /PATH_TO_RBE_V1/cron/water_meter_sync.php >> /PATH_TO_LOG/rbe_water_sync.log 2>&1
```

## V2 cron copies
V2 also contains corresponding Flecto sync scripts under `application/v2/cron/`. In the former operating environment the scheduled jobs were pointed at the V1 scripts. The V2 copies are retained as part of the V2 operating package, but RBE should avoid scheduling duplicate V1 and V2 ingestion jobs against the same database unless its developer has intentionally designed for that behaviour.

## V2 report archive retention
V2 includes:
- `application/v2/cron/purge_report_archives.php`

The script reads `global_settings.key = 'report_retention_years'` and defaults to five years if no configured value is available. No former production cron schedule for this script was captured in the handover inventory. RBE's developer may schedule it at an appropriate low frequency if report archive retention is used.

## Cron ownership
Creation, testing, monitoring, log rotation, retry strategy and destination cron configuration are RBE's responsibility in the new environment.
