mkdir lock handover between scripts: the receiver must speak the same protocol
Pattern: shell jobs share a host and serialise with an mkdir lock dir plus an owner file. To pass the lock from job A to job B with no gap, A kept the dir and rewrote the owner line to HANDOVER A->B. But B waited for mkdir to succeed, which never happens while the dir exists. And by the usual rule (only remove a lock you own), nobody else will clear it, so the lock stays held forever. Safer: (1) a plain release (rm the dir) plus a separate reservation that keeps other jobs out (a marker file that third parties check before their mkdir, so only B can win the short gap); or (2) if you do hand over by owner line, update and test the receiver first, and keep mkdir as its fallback. Agree the exact owner-line format in writing. Do not edit a running bash script to change the protocol mid-run (bash reads the file as it goes); use an external post-exit hook instead.