/batocera:batocera-maintenancefrom batocera
Use when keeping a Batocera cabinet healthy over time: running scripts or scheduled jobs at boot and on an interval without cron, the custom_service boot-service pattern (which replaced custom.sh in v43), backing up /userdata to another machine over SSH, and upgrading between major Batocera versions (v42 to v43 and similar) including the ROM-directory renames and post-upgrade checklist, a daily thermal throttle log, and a monthly health check that alerts only on an out-of-range value. Covers why there is no crond, the backup-before-upgrade doctrine, and catch-up scheduling. Not for performance tuning (batocera-tuning).
Ships in batocera. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Keeping the cabinet healthy: running things at boot and on a schedule, backing up
what matters, and surviving version upgrades. Assumes the connection pattern and
filesystem model from batocera-ops.
Batocera does not run a general-purpose crond. Don't write a crontab and
assume it fires; it won't. The mechanism for "run this at boot / on a schedule"
is a boot service.
Since v43, the entry point is /userdata/system/services/custom_service (it
replaced /userdata/system/custom.sh; the upgrade auto-converts an existing
custom.sh). A service is a script Batocera runs at boot with a start
argument. Enable/inspect services:
SSHB "batocera-services list"
SSHB "cat /userdata/system/services/custom_service"
To run something periodically, the service launches a background loop that sleeps and re-checks. This is how the cabinet does hourly/daily/monthly work with no cron:
# inside custom_service, on the 'start' case:
(
while true; do
# hourly re-assert (e.g. CPU governor; see batocera-tuning)
/etc/init.d/S18governor start 2>/dev/null
# once-a-day / once-a-month gating: compare a stamp file to `date`
stamp=/userdata/system/.last-monthly-backup
if [ "$(cat "$stamp" 2>/dev/null)" != "$(date +%Y-%m)" ]; then
/userdata/system/tools/backup-to-remote.sh && date +%Y-%m > "$stamp"
fi
sleep 3600
done
) &
Key ideas:
date +%Y-%m or %Y-%m-%d), not on "is it exactly 3 AM?".
A cabinet that's powered off at 3 AM would never run a clock-exact job; the
stamp approach runs it on the first boot of the new period instead./userdata/system/scripts/ — ES invokes
executables there as game event hooks (see batocera-ops → emulationstation).
Put tools in /userdata/system/tools/ or similar and call them from the
service.After editing custom_service, back it up first and test the loop logic before
relying on it (run the gated command by hand once).
Two small jobs for the boot service. Both exist because a cabinet fails slowly: dust builds up, the disk fills, a backup stops, and nobody looks.
Daily thermal throttle log.
scripts/throttle_log.sh appends one line with the
uptime, the CPU throttle counters, the hottest core temperature and the load.
scripts/throttle_loop.sh runs it at start and then
every 24 hours. The counters reset at boot, which is why each line carries the
uptime: compare two lines of the same boot. Start the loop from
custom_service with a guard so a second start does not add a second loop:
pgrep -f throttle_loop.sh >/dev/null 2>&1 || /bin/bash /userdata/system/health/throttle_loop.sh >/dev/null 2>&1 &
Verify after the next boot:
SSHB 'tail -3 /userdata/system/logs/throttle.log'
SSHB 'ps aux | grep -c "[t]hrottle_loop.sh"' # 1. Over SSH, pgrep -f would match your own command
A package_throttle_count that stays at 0 through a month of play means the
cooling is enough. A count that grows in summer and not in winter is a dust or
airflow job, not a software one (see batocera-tuning → reading an idle
machine).
Monthly health line. scripts/health_line.sh prints one line and changes nothing:
disk_used_pct=60 backup_age_days=12 throttle_pkg=0 uptime_days=0.4 watchdog_kills_30d=0 es_api=200
Disk use, days since the last good backup (the age of the backup job's stamp file), the throttle count, kills by a frontend watchdog in the last 30 days if you run one, and the HTTP code of the ES API. Run it once a month with the stamp pattern above, and send a message only when a value is out of range. A monthly "all fine" message trains everyone to ignore the channel; silence has to mean healthy, so the limits must be ones you would act on.
# inside the hourly loop of custom_service
stamp=/userdata/system/.last-health-check
if [ "$(cat "$stamp" 2>/dev/null)" != "$(date +%Y-%m)" ]; then
line=$(/bin/bash /userdata/system/health/health_line.sh)
val() { echo "$line" | tr ' ' '\n' | sed -n "s/^$1=//p"; }
bad=""
[ "$(val disk_used_pct)" -gt 85 ] 2>/dev/null && bad="$bad disk"
[ "$(val backup_age_days)" -le 45 ] 2>/dev/null || bad="$bad backup"
[ "$(val throttle_pkg)" -gt 0 ] 2>/dev/null && bad="$bad throttle"
[ "$(val watchdog_kills_30d)" -gt 2 ] 2>/dev/null && bad="$bad watchdog"
case "$(val es_api)" in 200|302) ;; *) bad="$bad frontend" ;; esac
[ -n "$bad" ] && curl -s -m 10 -d "cabinet health:$bad | $line" "$HEALTH_WEBHOOK"
date +%Y-%m > "$stamp"
fi
$HEALTH_WEBHOOK is whatever receives a POST on your network; keep its URL out
of any shared copy of the service file. The other way round also works and
keeps the cabinet free of alert logic: a home automation server or any
scheduler on another machine runs health_line.sh over SSH on day 1 and
compares the values there. That side can also report "cabinet did not answer",
which the cabinet cannot say about itself.
Test the alert path once, on purpose: run the block by hand with a limit that
must fail (-gt 1 for the disk) and confirm the message arrives. An alert
that has never fired is not known to work.
The doctrine: push-only, dry-run-first, over SSH. The cabinet pushes a copy
of the important parts of /userdata to another machine; you always dry-run an
rsync before letting it delete anything. Architecture, what to include/exclude,
and the catch-up schedule are in references/backup.md.
Back up before every upgrade. A major-version upgrade is the highest-risk routine event; a fresh backup of saves/system/bios (and ideally decorations/ shaders/themes) is the difference between a 10-minute rollback and a rebuild.
Major Batocera upgrades rename ROM directories, change the boot-service model, and swap emulators — each of which silently breaks things if you don't migrate. The v42→v43 migration (representative of the class) with the full rename table and a post-upgrade checklist is in references/v42-to-v43.md. What v44 changed is in references/v43-to-v44.md. The short doctrine:
batocera-tuning).references/backup.md (opens in a new tab)references/v42-to-v43.md (opens in a new tab)references/v43-to-v44.md (opens in a new tab)scripts/doom_import.py (opens in a new tab)scripts/health_line.sh (opens in a new tab)scripts/throttle_log.sh (opens in a new tab)scripts/throttle_loop.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub t3chnaztea/batocera-skills --plugin batocera5 skills in this plugin
/batocera-displayUse when working on how games look on a Batocera cabinet: CRT and other shaders, shaderset resolution and per-game shader overrides, bezel/overlay artwork and alignment, generating missing .info sidecars, filtering unusable bezels, seasonal bezels and boot splash clips, pinning the display resolution, or diagnosing moire and cropped/misaligned game viewports inside bezels. Covers why a shaderset seems invalid, why .info top values are not alpha coordinates, and why Mega-Bezel per-game art fails. Not for performance/framerate tuning (batocera-tuning)./batocera-opsUse when connecting to or operating a Batocera arcade/retro-gaming cabinet over SSH: establishing the connection, understanding its read-only rootfs and /userdata layout, finding config/log/ROM paths, applying changes safely, verifying a display/config change end-to-end without a controller, or diagnosing why a setting reverts to its default on every launch (configgen). Foundation for the other batocera-* skills (roms, display, tuning, maintenance). Covers sshpass, batocera.conf, EmulationStation, the ES HTTP API, and batocera-screenshot. Not for game recommendations./batocera-romsUse when working with ROMs and gamelists on a Batocera cabinet: figuring out which directory a system's ROMs go in, why a game does not appear in the menu, which file formats and extensions a system accepts, curating a large library by hiding rather than deleting, editing gamelist.xml safely, cleaning up multi-disc games, or verifying dumps against No-Intro/Redump DATs. Covers extensionless-ROM-in-zip failures, the 3DO/Opera no-m3u trap, cave3rd, and the es_systems_custom.cfg landmine. Not for shaders/bezels (batocera-display), or ROM directories renamed by a Batocera version upgrade (batocera-maintenance)./batocera-tuningUse when a Batocera cabinet feels slow, laggy, or stuttery, or when tuning performance: EmulationStation menu/carousel lag, a slow-since-boot frontend, CPU governor stuck in powersave, overclock or CPU-speed core options that seem to do nothing, run-ahead / input latency, joystick polling rate (usbhid.jspoll, 1000 Hz) on arcade encoders, framerate that drops the longer the machine runs, or a 3D-heavy game (PSX/PS2/Dreamcast/N64 class) that crashes or stutters — Vulkan errors in emulator logs, picking a rendering resolution or graphics backend the hardware can afford. Covers the diagnostic order (check the throttle first), the v43 governor-at-boot failure, the emulator-name vs rom-dir-name overclock scoping trap, ES event-hook frame cost, and hardware-tier detection (batocera-info / batocera-vulkan). Not for shader visual quality (batocera-display).