Text file busy 🐧 Linux

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

  1. Write to a temp file and mv it into place (atomic rename)
  2. Stop the process before replacing
  3. Wait for the writer to close the file

Detailed fix by platform

Linux

  1. 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

  1. Users — fuser -v /usr/local/bin/app
  2. 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:

🧠 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.