-1

I understand there is a usleep command in bash. Is this a "busy" or "blocking" sleep? Or will this yield time to other processes?

closed as off-topic by mdpc, Ward - Reinstate Monica, Tero Kilkanen, HBruijn Sep 30 '16 at 6:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – mdpc, Ward - Reinstate Monica, Tero Kilkanen, HBruijn
If this question can be reworded to fit the rules in the help center, please edit the question.

3

This probably don't really belong on Server Fault (though I'm not sure which site it would belong on), but here's an answer anyway:

The bash shell does not have a builtin usleep command (nor does it have a builtin sleep command). sleep is a standard program on Unix systems and is available regardless of which shell you're running. usleep appears to be a program that was written by people at RedHat and might only be present in RedHat-related distributions (RHEL and derivatives; Fedora). It doesn't appear to be available in Debian.

In any case, sleep and usleep use the standard sleep() and usleep() system calls, which pause program execution for the specified amount of time[0] (making them "blocking"), and use no CPU time during their sleep (making them not "busy").

[0] The amount of time isn't actually guaranteed to be precisely what was requested, because of the way the kernel scheduler works. The usual guarantee is that it will sleep for at least the requested time. This isn't an issue for integer sleep() durations, because the variance will be much less than a second, but usleep() durations (and fractional sleep() durations) might not end up being exact.

1

There is no usleep command in bash. usleep: command not found on bash 4.3.11 and nothing like that mentioned in the changelog ...

  • And it works - seems to yield - not block. – Mechi Fendel Sep 26 '16 at 11:32
  • Then this is not a bash builtin but an external utility. What does which usleep say? Why on earth should it block anyway? – Sven Sep 26 '16 at 11:34
  • 1
    usleep appears to be a RH/Fedora utility that only exists in these distributions as part of the initscripts package. – Sven Sep 26 '16 at 13:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.