What it does
sleep NUMBER[SUFFIX] pauses: s = seconds (default), m = minutes, h = hours, d = days. Decimals and more numbers (added together) are allowed. It is used in scripts and as a harmless test process in labs.
How to write it
sleep NUMBER[SUFFIX]...Options 3
Most used
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
1Wait 5 seconds
sleep 5No output; the prompt comes back after 5 seconds.
2Minutes and hours
sleep 2m; sleep 1.5hSuffixes s, m, h, d.
3Add values
sleep 1m 30sWaits 90 seconds.
4A test process for labs
sleep 3600 &Practice jobs, ps, kill and renice.
5Retry in a loop
until curl -fs http://localhost/health; do sleep 2; doneWait until a service answers.
6Pace a loop
for h in server1 server2; do ssh $h 'systemctl restart httpd'; sleep 30; doneRolling restart, one server at a time.
7Random delay for cron jobs
sleep $((RANDOM % 300)); /usr/local/bin/report.shNot all servers hit the API at the same second.
8Fractions of a second
sleep 0.2Short pauses in scripts.
9Stop a long sleep
kill %1sleep reacts to signals like other processes.
10Sleep forever (containers)
sleep infinityKeeps a test container running.
Nothing matches this filter.
Exit codes
0 | Done. |
1 | Error or interrupted by a signal. |