分类: LINUX
2011-04-30 11:13:52
This is the shell equivalent of a wait loop. It pauses for a specified number of seconds, doing nothing. It can be useful for timing or in processes running in the background, checking for a specific event every so often (polling), as in .
sleep 3 # Pauses 3 seconds. |
The sleep command defaults to seconds, but minute, hours, or days may also be specified.
|
The command may be a better choice than sleep for running commands at timed intervals. |
Microsleep (the "u" may be read as the Greek "mu", or micro- prefix). This is the same as sleep, above, but "sleeps" in microsecond intervals. It can be used for fine-grain timing, or for polling an ongoing process at very frequent intervals.
usleep 30 # Pauses 30 microseconds. |
This command is part of the Red Hat initscripts / rc-scripts package.
The usleep command does not provide particularly accurate timing, and is therefore unsuitable for critical timing loops. |