Text file busy (ETXTBSY) when replacing or running a binary
You tried to overwrite an executable that is currently running, or run one that is still open for writing.
Seen on:
Linux
Meaning
Linux won’t let a running program’s file be modified in place. Deploy scripts that cp over a running binary, or scripts executed right after being written (still open), hit ETXTBSY.
Common causes
- Overwriting a running binary with cp
- Executing a file another process still has open for writing
- Copying a script and running it immediately in parallel
⚡ Quick fix
- Write to a temp file and mv it into place (atomic rename)
- Stop the process before replacing
- Wait for the writer to close the file
Detailed fix by platform
Linux
- bash
cp app.new /usr/local/bin/app.tmp && mv /usr/local/bin/app.tmp /usr/local/bin/app sudo systemctl restart app
How to diagnose
- Users — fuser -v /usr/local/bin/app
- Deploy — cp or mv?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Linux
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026