Best Fixes
Identify the process still using the file, then stop it or replace the file via a safer deploy pattern.
Use atomic moves or versioned artifacts instead of overwriting an actively used executable in place.
Why Linux blocks execution or replacement of a file in use and how to recover cleanly.
This usually happens when you try to overwrite or execute a file while another process still has it open in a way the system will not allow. It is common in deploy and build scripts.
Identify the process still using the file, then stop it or replace the file via a safer deploy pattern.
Use atomic moves or versioned artifacts instead of overwriting an actively used executable in place.
Do not retry blindly if your deploy process is racing with a live process.
Do not patch around the issue without understanding which process still owns the file.