System and processes
The sleep command
Waits for the given time before continuing. Useful in scripts between two steps.
Most useful options
--helpShows the help and exits--versionShows the version and exitss, m, h, dSuffixes for seconds, minutes, hours and days. Without a suffix it means seconds: sleep 1m is the same as sleep 600.5Accepts decimals: sleep 0.5 waits half a secondCopy-ready examples
$ sleep 2waits 2 seconds.$ sleep 1mwaits 1 minute.$ sleep 3 && echo listowaits and then prints the message.Example output
listo
$ sleep 0.5 && echo okwaits half a second, using decimals.Example output
ok
You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| sleep: missing operand | You ran sleep without any time. | Give the time, for example sleep 5. To see the help, use sleep --help. |
| sleep: invalid time interval 'abc' | The value is not a number. Text was passed where the time should go. | Write a number, with an optional suffix: sleep 10 or sleep 10s. |
| sleep: invalid time interval '1x' | The suffix does not exist. Only s, m, h and d are accepted. | Change the suffix: sleep 1m instead of sleep 1x. |
Typical mistakes
- Without a suffix the number means seconds: sleep 60 waits one minute, not an hour.
- With several arguments it adds their values: sleep 1 2 waits 3 seconds.
- Do not confuse sleep (wait) with systemctl suspend (suspend the machine).
- A fixed wait checks nothing: if the previous step takes longer, sleep does not know. To wait for something specific, use a loop that checks before continuing.
Differences from similar commands
FAQ
Can I stop it?
Ctrl+C interrupts the wait. Ctrl+Z suspends the process, and fg resumes it from the same point.
Does it accept decimals?
Yes: sleep 0.5 waits half a second. The manual accepts integers or floating-point numbers.
What happens if I pass several times?
They are added up. sleep 1m 30 waits 90 seconds, and sleep 0.2 0.1 waits 0.3.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course