Jump to content

sleep (command)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 118.208.92.8 (talk) at 09:58, 5 December 2016 (Options). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

sleep is a Unix command line program that suspends program execution for a specified time. The sleep instruction suspends the calling process for at least the specified number of seconds (the default), minutes, hours or days.

Usage

 sleep number

Where number is an integer number to indicate the time period in seconds. Some implementations may support floating point numbers.

Options

None.

Examples

 sleep 30

Causes the current terminal session to wait 5 seconds.

 sleep 18000

Causes the current terminal session to wait 5 hours

GNU sleep specific Examples

 sleep 3h ; mplayer foo.mp3

Wait 3 hours then play foo.mp3

Note that sleep 5h30m and sleep 5h 30m are illegal since sleep takes only one value and unit as argument. However, sleep 5.5h is allowed. Consecutive executions of sleep can also be used.

 sleep 5h; sleep 30m

Sleep 5 hours, then sleep another 30 minutes .

The GNU Project's implementation of sleep (part of coreutils) allows the user to pass multiple arguments, therefore sleep 5h 30m (a space separating hours and minutes is needed) will work on any system which uses GNU sleep, including Linux.

Possible uses for sleep include scheduling tasks and delaying execution to allow a process to start, or waiting until a shared network connection most likely has few users to wget a large file.

See also