---
name: "sleep"
section: "1"
platform: "macos"
package: "shell_cmds"
version: "329"
release: "macOS 26.5"
platforms: ["linux", "freebsd", "openbsd", "macos"]
url: "https://new.carta.tech/sleep"
---

# sleep(1)

suspend execution for an interval of time

## NAME

**sleep** – suspend execution for an interval of time

## SYNOPSIS

**sleep** *number*\[*unit*\] \[...\]

## DESCRIPTION

The **sleep** command suspends execution for a minimum of *number* seconds (the default, or unit s), minutes (unit m), hours (unit h), or days (unit d). Intervals can be written in any form allowed by [strtod(3)](/strtod/3.md). If multiple intervals are given, they are added together. If the final sum is zero or negative, **sleep** exits immediately.

If the **sleep** command receives a signal, it takes the standard action. When the SIGINFO signal is received, the estimate of the amount of seconds left to sleep is printed on the standard output.

## IMPLEMENTATION NOTES

The SIGALRM signal is not handled specially by this implementation.

## EXIT STATUS

The **sleep** utility exits 0 on success, and \>0 if an error occurs.

## EXAMPLES

To run a command after half an hour:

```
(sleep 0.5h; sh command_file >out 2>err)&
```

This incantation would wait half an hour before running the script *command\_file*. See the [at(1)](/at/1.md) utility for another way to do this.

To reiteratively run a command:

```
while :; do
	if ! [ -r zzz.rawdata ] ; then
		sleep 5m
	else
		for i in *.rawdata ; do
			sleep 70
			awk -f collapse_data "$i"
		done >results
		break
	fi
done
```

The scenario for a script such as this might be: a program currently running is taking longer than expected to process a series of files, and it would be nice to have another program start processing the files created by the first program as soon as it is finished (when *zzz.rawdata* is created). The script checks every five minutes for the file *zzz.rawdata*, when the file is found, then another portion processing is done courteously by sleeping for 70 seconds in between each [awk(1)](/awk/1.md) job.

## SEE ALSO

[nanosleep(2)](/nanosleep/2.md), [sleep(3)](/sleep/3.md)

## STANDARDS

The **sleep** command is expected to be IEEE Std 1003.2 (“POSIX.2”) compatible.

Support for non-integer intervals, units other than seconds, and multiple intervals which are added together are non-portable extensions first introduced in GNU sh-utils 2.0a (released in 2002).

## HISTORY

A **sleep** command appeared in Version 4 AT&T UNIX.
