I have a little script that have to remove some files.
How can I manage the device or resource busy
error of rm
?
Can I catch it? Like a try/catch?
So that if I catch it I, for example, sleep 3 seconds and then retry..
Thanks
I have a little script that have to remove some files.
How can I manage the device or resource busy
error of rm
?
Can I catch it? Like a try/catch?
So that if I catch it I, for example, sleep 3 seconds and then retry..
Thanks
If it's an error that you think will go away after some time, then you could try a simple loop:
while ! rm some files; do
echo 'rm failed, sleeping for 5 seconds'
sleep 5
echo 'retrying...'
done