I have a bash script file where I execute a bunch of commands.
#!/bin/bash umount /media/hdd1 umount /media/hdd2 something1 something2
But since the comands later in the file work with the umounted HDD, I need to make sure the umount is successful before continuing.
I can of course check if the umount failed and just exit 1, but that is not ideal.
So basically, what I would like to do, is somehow make the umount command wait, until the device is not busy and then umount the HDD and continue executing the script.
It would thus work like this:
#!/bin/bash umount /media/hdd1 # Device umounted without any problems continuing the script.. umount /media/hdd2 # Device is busy! Let's just sit around and wait until it isn't... let's say 5 minutes later whatever was accessing that HDD isn't anymore and the umount umounts the HDD and the script continues something1 something2