Let's assume that another user started a bunzip process, and I have a script that I'd like to start running after that bunzip finishes. What's the best way to check from inside my script that the bunzip process has finished? A call to
ps with the pid specified? A pgrep bunzip? Assume that I will throw my script into a crontab that checks every 5 minutes to see if it can run. Also assume that I don't want to stop the bunzip, as it's been running for over an hour and will likely take another hour to complete.
My first reaction would be to use something like
if `ps -p 12938` # bunzip is done, execute the code fi # exit
But, I'm wondering if there is a better way. Also, I'm not sure how cross-unix ps -pid is.