Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
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.
Zo schrijf je het
sleep NUMBER[SUFFIX]...Opties 3
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met 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.
Niets past bij dit filter.
Exitcodes
0 :: Done. 1 :: Error or interrupted by a signal.