◉CLAUDE LABJP
●2.1.296 — Subagents can set their own autoCompactWindow, and an env var pins the model used by workflow agents●AGENTS — Managed Agents gain dynamic workflows in beta: an agent can build a run for work with many pieces (Oct 9)●SONNET 4.5 — Retires on the Claude API on 11/30, 48 days left. Migrate to Sonnet 5.5●Q&A — A write-up shows how to stop a streaming call midway so a closed tab stops being billed●WORKTREE — Running claude --worktree on one repo in parallel: what to settle first, as one write-up lays it out●NEW — Stop making it reread the whole notes file: look up one section by number●2.1.296 — Subagents can set their own autoCompactWindow, and an env var pins the model used by workflow agents●AGENTS — Managed Agents gain dynamic workflows in beta: an agent can build a run for work with many pieces (Oct 9)●SONNET 4.5 — Retires on the Claude API on 11/30, 48 days left. Migrate to Sonnet 5.5●Q&A — A write-up shows how to stop a streaming call midway so a closed tab stops being billed●WORKTREE — Running claude --worktree on one repo in parallel: what to settle first, as one write-up lays it out●NEW — Stop making it reread the whole notes file: look up one section by number
Articles/Cowork
◈ Cowork/2026-08-29Advanced

The lock I left in a shared folder shut out every run after the first

A cloud-synced connected folder allows create, append, and rename, but refuses delete. Putting a single-instance lock there quietly disabled every unattended run after the first. Measurements for three lock styles, plus an implementation that picks a safe location.

Cowork44scheduled tasks12connected folderlockingunattended automation6

✦ Premium Article

A job I had queued the night before finished with a single line in the log. Not an error. Just the branch I had written myself: "another process is running, skipping this round."

No other process was running.

As an indie developer I hand more and more of the routine work to unattended scheduled runs, and several of those runs touch the same connected folder. Double execution was the one thing I wanted to rule out, so I added a lock. The mistake was where I put it — in the most reliably shared place I could think of, which was the connected folder itself.

The mutual exclusion worked. It worked so well that it never let go.

The locking part was fine

My first suspicion was the acquisition logic. If nothing was competing but the code said otherwise, the condition must be wrong. So I checked whether exclusion was happening at all.

# hold the lock for 3 seconds in one shell, then try a second one
( flock -n 9 && sleep 3 ) 9> "$SHARED/slot.lock" &
sleep 0.5
( flock -n 9 && echo "second acquired (unexpected)" \
              || echo "second blocked (as expected)" ) 9> "$SHARED/slot.lock"
wait

The answer came back second blocked (as expected). flock behaves correctly on this folder. This was not the classic story of advisory locks failing over a network filesystem.

The problem was on the other side of the lock's life.

Only deletion was refused

I broke a file's life cycle into individual operations and ran each one in the same place: create, append, read, rename, make a directory, and remove.

T="$SHARED/probe_test"
echo x >  "$T"          # create
echo y >> "$T"          # append
cat "$T" > /dev/null    # read
mv  "$T" "$T.renamed"   # rename
rm -f "$T.renamed"      # delete
mkdir "$SHARED/probe_dir" && rmdir "$SHARED/probe_dir"

Here is what my environment returned.

OperationConnected folder (cloud-synced)Local sandbox storage
Create (>)OKOK
Append (>>)OKOK
ReadOKOK
Rename (mv)OKOK
Create directory (mkdir)OKOK
Delete (rm)Operation not permittedOK
Remove directory (rmdir)Operation not permittedOK

A writability check passes here. Mine did. You can create, you can append, you can even rename, so as far as write permission goes nothing is wrong.

Deletion is the only refusal. And a single-instance lock is a mechanism that only works if you can delete it.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦You will be able to tell, before the second unattended run, whether your lock style can actually be released where you put it
✦You will be able to swap mkdir locks, noclobber locks, and flock for a form that stays correct even when deletes are refused
✦You will be able to turn lock-caused skips into recorded outcomes instead of silent successes, so a job cannot sit dead for days unnoticed
✦You will be able to find two races hiding in lock-location choice and lock cleanup by running two copies at once on your own machine
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $15 for lifetime access
View Membership →

Related Articles

◈ Cowork2026-09-16
The scheduled task that only ran on days my desk was awake
Cowork scheduled tasks run remotely by default, but the moment one needs a local file or app, it runs only on your machine. Here is how the last field in the setup dialog decides that, and the three questions I now answer before creating a task.
◈ Cowork2026-09-15
What you keep the agent from walking matters more than what you hand it
Searching one connected Cowork folder for the same word gave three different answers. Here is what the default search silently left out, and how to measure a folder's scan scope once before you hand it over.
◈ Cowork2026-09-05
I verify what my Cowork memory claims instead of trusting its timestamp
Persistent memory keeps asserting whatever was true the day you wrote it. After an unattended job quietly read an empty folder for months, I stopped judging memory by its modification date and started attaching a verification step to every claim that can rot.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links