📝 cleanISE_Clone_manual.mdv4.6.0 · 2026-10-19

cleanISE_Clone -- manual

Version: 1.0.4 (2026-10-16) Runs on: Clone, as root. Lives in /bin (Clone's /bin is the master). Author: Another collaboration between Andrew.human and Claude.ai

Purpose

Keeps /var/www/html/ISE_Data free of leftovers, so it can be run often. It is deliberately small: it matches five kinds of file and nothing else.

Usage

cleanISE_Clone                      # dry run: prints what it would do, changes nothing
cleanISE_Clone --apply # does it
cleanISE_Clone --version # prints the version and exits
cleanISE_Clone -h # prints the usage and exit-code lines

--all-checkpoints (the v1.0.1 option) is still accepted, so older command lines keep working, but it does nothing: since v1.0.3 that behaviour is the default.

Run it with bash cleanISE_Clone or directly (./cleanISE_Clone, /bin/cleanISE_Clone), never with sh. On CentOS 6 sh is bash in POSIX mode, which refuses the done < <(find ...) loops: syntax error near unexpected token '<'.

The version line is printed once, at the start of every run.

Exit codes: 0 ok, 1 ISE_Data missing or an action failed, 2 bad argument, 3 the old-named checkpoint files were left alone because something is running (the other rules still ran).

Rules

Only files directly inside ISE_Data are looked at (no subdirectories).

# Matches Condition Action
1 *.tmp older than TMP_MIN (60 min) deleted
2 *.log bigger than LOG_MAX_KB (2048 KB) copied to <name>.log.1 (old .1 becomes .2, old .2 overwritten), then the original is emptied in place
3a processor_checkpoint.json and processor_checkpoint_i*of*.json (the names MediaProcessor used before v9.30) nothing is running: any age. Something is running: only the _i*of* ones, and only if older than CKPT_MIN (1440 min = 1 day) deleted
3b processor_checkpoint_i*of*.ckpt (current per-instance names, MediaProcessor v9.30 and later) older than CKPT_MIN (1440 min = 1 day) deleted
4 audio_store.json.pre* (hand-made restore copies, e.g. audio_store.json.pre2419) older than PRE_MIN (10080 min = 7 days) deleted
5 audio_store.json.lock older than PIDLOCK_MIN (60 min) and the process id written in it (pid N, started ...) no longer exists deleted

The five values (TMP_MIN, LOG_MAX_KB, CKPT_MIN, PRE_MIN, PIDLOCK_MIN) and the two paths (DIR = /var/www/html/ISE_Data, PROJ = /var/www/html/The_ISE_Project) are variables at the top of the script.

Rule 5 prints left alone instead when the file has no pid N, in it, or when process N still exists.

"Nothing running"

Only rule 3a depends on it. The script counts something as running if any of these is true:

When any of them is found, the script prints what it found, leaves the checkpoint files rule 3a would have removed, still runs every other rule, and exits 3. A plain shell script that holds none of those locks is not detected.

Checkpoint file names

MediaProcessor v9.30 writes processor_checkpoint.ckpt and processor_checkpoint_i<k>of<N>.ckpt (still JSON inside). The .ckpt names are deliberately not matched by the .json rule, so the last run's checkpoint survives cleanup. Old-named .json files already in ISE_Data are removed by rule 3a when nothing is running. Anything outside MediaProcessor that reads processor_checkpoint.json must be changed to the new name.

Never touched

No rule matches any of these, so they are never removed or changed: *_store.json, word_index*.json, processor_checkpoint.ckpt, audio_checkpoint.json, caption_failures.json, chain_snapshot.json, orphan_state.json, pdf_duplicates.json, pdf_dupe_deleted.json, and the lock files .mediaprocessor.lock and .mediawatchdog.lock.

Deliberately not included

Cron (suggested, not installed)

23 * * * * /bin/cleanISE_Clone --apply >> /var/log/cleanISE_Clone.log 2>&1

Each run writes a few lines, so that log grows slowly. Check it now and then. The cron line needs --apply; without it every run is a dry run. An exit code of 3 in that log only means a job was running at that moment and the old-named checkpoints were left until the next run.

Notes

Version history

Version Date Change
1.0.0 2026-10-12 First release: stale *.tmp removal, size-capped *.log rotation, old per-instance processor checkpoint removal. Dry run by default.
1.0.1 2026-10-16 Added --all-checkpoints: also removes processor_checkpoint.json and every per-instance checkpoint regardless of age, but only when nothing is running (exit 3 if something is). Arguments can be combined (--apply --all-checkpoints).
1.0.2 2026-10-16 Rule 4: audio_store.json.pre* older than 7 days is removed.
1.0.3 2026-10-16 Removing the old-named checkpoints when nothing is running is now the default (--all-checkpoints still accepted, does nothing). Goes with MediaProcessor v9.30 (.ckpt names): old .json names removed when idle, .ckpt names kept (per-instance ones once older than CKPT_MIN).
1.0.4 2026-10-16 Rule 5: a stale audio_store.json.lock (pid gone, older than 60 minutes) is removed.