How to make a short delay (for less than a second) in bash? The smallest time unit in sleep command is 1 sec. I am using bash 3.0 in SunOS 5.10.
SunOS (Solaris) probably doesn't have the GNU tools installed by default. You might consider installing them. It's also possible that they're already installed in your system, perhaps in some directory that isn't in your default $PATH
. GNU sleep
is part of the coreutils package.
If you have Perl, then this:
perl -MTime::HiRes -e 'Time::HiRes::usleep 500000'
should sleep for 500000 microseconds (0.5 second) -- but the overhead of invoking perl is substantial.
For minimal overhead, I'd write a small C program that calls usleep()
or nanosleep()
. Note that usleep()
might not handle intervals greater than 1 second.