I have a deployment script that removes all files in a tmp folder before continuing, but sometimes during the deployment, a process will use one of the tmp files, making the rm
command fail. This is how my script looks like
rm -rf app/tmp
tar -xf app.tar
That is an over-simplification of what is happening, please don't try to suggest improving the deployment process, this is strictly a question about the rm
command
I am thinking of something like
# pseudo code
while [[ ! rm -rf app/tmp ]]; do sleep 1; done
tar -xf app.tar
In other words: continue to try to delete folder until nobody added files there, then continue the script.
Do you know of a syntax that would allow this in bash?
Currently the script fails and never extracts the tar files.
Thanks for your input here.