BASH: Waiting for a process to end, problem with wait
Hi there folks, i came along with yet another issue with the wait command in BASH
The thing is i used BASH to run another script which is not mine, several times in a for loop. But i need to open the log files after each time the script that modifies some text file is done. I tried with wait and using the PID, but it says something like the process is not spawned from that console/terminal, so i recurred to a more dumb approach: Code:
# Wait till current file is gone |
If you are going to use a busy loop to wait for a non-child process, at least put a delay time in the loop, otherwise you will be wasting CPU cycles (and electricity). For example, the following bash code will busy-wait for a process to finish:
Code:
while [ -e /proc/$PID ]; do sleep 0.1; done |
If you want a dummy command, : is provide for exactly that purpose
Code:
c@CW8:~$ help : |
All times are GMT -5. The time now is 10:19 PM. |