waitfor

Wait for a pathname test, external command, or other testable condition

For use in rc scripts and similar situations, in which dependancies on remote files or devices may temporarily fail e.g. due to a power failure taking down the remote server.

Options:

-v = verbose mode (default = silent)
-s delay_in_secs (default 180)
delay between each test of the condition
-n number_of_tries (default 20)
number of times to try before giving up
-e eval expression before testing
Run the expression through 'eval' first, to expand certain constructs like "~user"
-d direct execution - don't run inside [ ]
execute the test directly (for an external command or pipeline), instead of via [ ]
Arguments:
Test flags and arguments as would be passed to test(1), or an external command to run. Since in general this will begin with a "-", local options should be terminated with "--". The test string may be specified as a single argument (in quotes) or as multiple arguments. Parentheses used for grouping the test components must be enclosed in quotes and backslash-escaped.

Exit status:

0 If test succeeds before iteration limit is reached
1 If test still fails when iteration limit is reached
Examples
waitfor -- -x /usr/local/sbin/sidecar
Test for an executable file /usr/local/sbin/sidecar, which may not initially be accessible. Keep trying for up to 1 hour.
waitfor -s10 -n6 -e -- "\( -w /var/tmp/log1 -a -w /var/tmp/log2 \) -o -w /var/tmp/combinedlogs"
Test for writeable files /var/tmp/log[12] OR the single file /var/tmp/combinedlogs. Check every 10 seconds, but no more than 6 attempts before giving up.
waitfor -d -- 'mount | grep -q /backup'
Test that /backup is a mount point and wait if it is not.
2004/03/21 Richard Brittain, Dartmouth College Computing Services.
Last update: 2010/03/19
Richard's Software Page
Richard Brittain