sleep (command line command)
sleep is a command line which in Unix , Unix-like operating systems , Windows and FreeDOS as a system call a running process pauses for a specified period of time.
General examples
The sleep
statement interrupts the currently running process for the specified number of seconds (by default ), minutes or hours:
sleep [Zeit]
with an integer value for time indicating the time period in seconds.
The current process waits 30 seconds:
sleep 30
Or even 5 hours:
sleep 18000
Unix and Unix operating systems
Wait 3 hours and then play the file foo.mp3 :
sleep 3h ; mplayer foo.mp3
Expressions like sleep 5h30m
and sleep 5h 30m
generate error messages because the sleep
command expects a value and (optionally) a unit as arguments. Operating systems using GNU (including Linux ), however, provide the notation with mandatory spaces to separate hours and minutes.
sleep
sleep 5h 30m
Floating point numbers prevent confusing time specifications in mere seconds.
Wait 5.5 hours:
sleep 5.5h
The sequence of sleep
commands serves the same purpose.
Take a break for 5 hours and then another 30 minutes:
sleep 5h; sleep 30m
Greet the currently logged in user (user, here root), wait 5 seconds and say goodbye at the end:
Windows
The PowerShell Windows defines the sleep
command through an alias for the cmdlet Start-Sleep
and Microsoft provides a Resource Kit tool for sleep
ready. Within a batch file or via a Windows command prompt , the command interrupts the execution of the program for a freely selectable time.
Newer versions of Windows also support the use of the timeout
command.
application areas
The Windows Task Scheduler and Cron in UNIX use the sleep
command to schedule processes or to delay their execution.
In a divided network , the sleep
command limits the number of users who want to download a large file (e.g. with the Unix wget command ).
Individual evidence
- ^ Ibiblio: Package group Utilities. Retrieved September 18, 2018 .
- ↑ die.net: sleep (3): sleep for specified number of seconds - Linux man page. Retrieved September 18, 2018 .
- ↑ Gnu.org: GNU Coreutils: sleep invocation. Retrieved September 18, 2018 .
- ^ Microsoft : Start-Sleep. Retrieved September 18, 2018 .
- ↑ Microsoft : Download Windows Server 2003 Resource Kit Tools from Official Microsoft Download Center. Retrieved September 18, 2018 .
- ↑ Microsoft : Timeout Microsoft Docs. Retrieved September 18, 2018 .
- ↑ Groovy Post: Schedule Windows to Sleep and Wake Automatically. Retrieved September 18, 2018 .
- ↑ LazyDev: cron vs sleep which is better? Retrieved September 18, 2018 .
Web links
-
sleep(3)
- Open Group Base Specification