Add daily 03:30 export schedule (systemd timer)
This host has no cron daemon (it is systemd-based), so schedule export-runner.sh via a
systemd timer rather than cron. cron-export.sh wraps the run with a sane PATH, flock
serialisation (no overlapping runs), and per-run logs under runtime/logs/. The timer is
Persistent, so a 03:30 run missed because the machine was asleep/off is caught up on the
next boot -- which plain cron does not do.
- scripts/cron-export.sh: scheduled-run wrapper.
- deploy/systemd/ctrader-export.{service,timer}: the units (install: sudo cp into
/etc/systemd/system/ then enable -- see deploy/systemd/README.md).
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
# Scheduled export (systemd timer)
|
||||
|
||||
Runs `scripts/export-runner.sh` once a day at **03:30** via a systemd timer (this host
|
||||
has no cron daemon; the timer is native and, unlike cron, catches up a missed run with
|
||||
`Persistent=true` if the machine was asleep/off at 03:30).
|
||||
|
||||
`ctrader-export.service` runs `scripts/cron-export.sh` as user `brummel` (a wrapper that
|
||||
sets a sane PATH, serialises with `flock`, and logs into `runtime/logs/`).
|
||||
|
||||
## Install (one-time, needs sudo)
|
||||
|
||||
```bash
|
||||
sudo cp deploy/systemd/ctrader-export.service deploy/systemd/ctrader-export.timer \
|
||||
/etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now ctrader-export.timer
|
||||
```
|
||||
|
||||
## Verify / operate
|
||||
|
||||
```bash
|
||||
systemctl list-timers ctrader-export.timer # next/last fire time
|
||||
systemctl status ctrader-export.service # last run result
|
||||
journalctl -u ctrader-export.service # service-level logs
|
||||
ls -t runtime/logs/ # per-run export logs
|
||||
sudo systemctl start ctrader-export.service # run once now, on demand
|
||||
sudo systemctl disable --now ctrader-export.timer # stop scheduling
|
||||
```
|
||||
|
||||
Paths in the unit files are absolute (`/home/brummel/dev/cTrader`). If the repo moves,
|
||||
update `ExecStart` in `ctrader-export.service` and re-run the install steps.
|
||||
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=cTrader MS_SimpleExport daily market-data export
|
||||
# The export writes to the NFS-mounted data dir and logs into cTrader over the network.
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=brummel
|
||||
SupplementaryGroups=docker
|
||||
ExecStart=/home/brummel/dev/cTrader/scripts/cron-export.sh
|
||||
# A full run is ~15-20 min; allow generous head-room for gap backfills.
|
||||
TimeoutStartSec=2h
|
||||
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=Run the cTrader market-data export daily at 03:30
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 03:30:00
|
||||
# Catch up a missed run (e.g. the machine was asleep/off at 03:30) on next boot.
|
||||
Persistent=true
|
||||
Unit=ctrader-export.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
Reference in New Issue
Block a user