◉CLAUDE LABJP
●CC 2.1.332 — 2.1.332 (11/25) is still current. Skills from MCP servers appear as server:skill (beta)●OPUS 4.5 — Opus 4.5 is now scheduled to retire from the Claude API on 2027/1/22. Move to claude-opus-5-5●SONNET 4.5 — Sonnet 4.5 retires from the Claude API tomorrow, 11/30. Last day to check for hard-coded IDs●DISK — Users on Windows report Cowork's session disk filling up with no way to clean it●NEW — New: Asking Cowork for a meeting draft? Hand over old minutes after the outline is set●JETBRAINS — Our guide to using Claude with JetBrains IDEs is still among the most-read pages●CC 2.1.332 — 2.1.332 (11/25) is still current. Skills from MCP servers appear as server:skill (beta)●OPUS 4.5 — Opus 4.5 is now scheduled to retire from the Claude API on 2027/1/22. Move to claude-opus-5-5●SONNET 4.5 — Sonnet 4.5 retires from the Claude API tomorrow, 11/30. Last day to check for hard-coded IDs●DISK — Users on Windows report Cowork's session disk filling up with no way to clean it●NEW — New: Asking Cowork for a meeting draft? Hand over old minutes after the outline is set●JETBRAINS — Our guide to using Claude with JetBrains IDEs is still among the most-read pages
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.

Cowork71scheduled tasks13connected 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 $10 for lifetime access
View Membership →

Related Articles

◈ Cowork2026-10-16
The Token-in-URL Way of Authenticating git Stopped Working in One Scheduled Task
A git clone stopped with 'could not read Username'. Two ways of putting a token in the URL behaved differently, and this is how I ended up on askpass.
◈ 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.