I have a bash script which calls an external program I cannot modify. The first stage of this program uses high IO and the second stage uses almost no IO, instead it uses a lot of CPU, it does not provide any output which indicates which stage it is on. I want to call this program, wait until it's done with the IO-heavy stage, and then continue running the rest of my script. In pseudocode it would be something like this

execute externalscript
while total io for last 30 seconds > 1MB;do sleep 30s;done;continue script
<.. rest of script..>

What methods could I use to monitor the IO? I am familiar with iotop, just wondering if there's a more direct way than parsing its output.

  • 1
    Take a look at unix.stackexchange.com/questions/206252/… . Maybe you can monitor /proc/<pid>/io and see when some of the values there stop going up quickly. - I just looked up "how does iotop work". pid is the process id of the external script which can be accessed with $! as soon as the external program is launched by your script if the command ends in ` &` so the script isn't waiting for it to complete. – Joe Mar 2 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.