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
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.
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).
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.
Only rule 3a depends on it. The script counts something as running if any of these is true:
python*, py, ffmpeg, ffprobe or llama-mtmd-cli whose working directory is PROJ, or whose command line contains PROJ or DIR, or that has a file open under DIR;flock -n): .mediaprocessor.lock, .mediawatchdog.lock, audio_store.json.lock (all in ISE_Data) and MediaIndexer.lock (in $TMPDIR, else /tmp);flock is not installed (the locks cannot be checked, so it is treated as busy).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.
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.
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.
word_index_media.json: no .php, .py or .sh under the web root names it, but the md5 comparison scripts do not exclude it, so removing it means removing it from Live, Clone and Dev together. Do that by hand if wanted.rw-rw-rw- on some files): set by whatever creates the files and carried by the mirrors. Fix at the source, not here..mediaprocessor.lock, .mediawatchdog.lock: empty files that programs lock with flock. The lock belongs to the open file, not to the name, and the OS drops it when the program ends, so they cannot go stale. Deleting one while it is held lets a second program lock a new file of the same name, and both then think they hold the lock.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.
-mmin uses the file's modification time, so a checkpoint or .tmp being written right now is never old enough to match.flock on audio_store.json.lock and a new job starts in the instant between the script's check and its delete, two jobs could run at once. The age and process checks make that very unlikely.embeddings_store.json, so deleting a checkpoint loses no work.| 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. |