# Sample crontab entry for mempalace-session inside a long-running # opencode-devbox container, scheduled from the DOCKER HOST (not inside # the container — containers typically don't run cron). # # Host-side cron runs `docker exec` against the running container once a # week. Requires: # - Container is long-lived (compose up, restart: unless-stopped, etc.) # - User running cron has rights to talk to the docker socket # (usually means being in the `docker` group, or on macOS having # Docker Desktop running for the current login session) # - `mempalace-session` is already installed inside the container # (opencode-devbox bakes it in via cli_utils → mempalace-toolkit) # # Install: # # Replace CONTAINER / USER / HOST_USER to match your setup, then: # (crontab -l 2>/dev/null; cat contrib/cron/mempalace-session-devbox.cron) | crontab - # # Adjust CONTAINER and USER below before installing. # # Design notes: # - `docker ps --filter name=... --filter status=running` makes the job a # no-op if the container is down, so the timer is harmless on machines # where the devbox is currently stopped. No mail/warning/noise. # - Exec runs as `developer` (the opencode-devbox user). Change `-u` # if you named your user something else. # - Output is captured in a log under the HOST user's home, not inside # the container — so you can inspect it from outside. CONTAINER=opencode-devbox CONTAINER_USER=developer # HOST_USER is used only to anchor the log path. Replace with your host # username (or leave the $HOME substitution if your cron implementation # expands it — most do). PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin # m h dom mon dow command 0 3 * * 1 /bin/sh -c 'docker ps --filter "name=^/${CONTAINER}$" --filter "status=running" -q | grep -q . && docker exec -u "${CONTAINER_USER}" "${CONTAINER}" mempalace-session >> "$HOME/.cache/mempalace-session/cron-devbox.log" 2>&1'