# Explorer maintenance cron

Automated jobs to prevent 502s, disk full, and nginx downtime on VMID 5000 (explorer.d-bis.org).

## Install (one-time)

From the **explorer-monorepo** directory:

**On Proxmox host that has VMID 5000:**
```bash
bash scripts/cron/install-explorer-cron.sh
```

**From your machine (SSH to node):**
```bash
EXPLORER_VM_HOST=root@192.168.11.12 bash scripts/cron/install-explorer-cron.sh
```

## What gets installed (inside VMID 5000)

| Schedule | Job | Purpose |
|----------|-----|--------|
| Every 5 min | `/usr/local/bin/explorer-maintain.sh` | If API ≠ 200: restart Blockscout or start from docker-compose. If nginx inactive: start nginx. |
| Daily 03:15 | `RUN_PRUNE=1 /usr/local/bin/explorer-maintain.sh` | If disk usage ≥ 90%: safe prune (unused images + build cache only; **no** container prune). |

Log file: `/var/log/explorer-maintain.log` (inside the VM).

## Verify

```bash
# On Proxmox host
pct exec 5000 -- crontab -l
pct exec 5000 -- tail -20 /var/log/explorer-maintain.log
```

## Uninstall

```bash
pct exec 5000 -- bash -c '(crontab -l 2>/dev/null | grep -v explorer-maintain | grep -v /usr/local/bin/explorer-maintain.sh) | crontab -'
pct exec 5000 -- rm -f /usr/local/bin/explorer-maintain.sh
```
