sleep (command line command)

from Wikipedia, the free encyclopedia

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 sleepstatement 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 5h30mand sleep 5h 30mgenerate error messages because the sleepcommand 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. sleepsleep 5h 30m

Floating point numbers prevent confusing time specifications in mere seconds.

Wait 5.5 hours:

sleep 5.5h

The sequence of sleepcommands 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:

Sleep Command

Windows

The PowerShell Windows defines the sleepcommand through an alias for the cmdlet Start-Sleep and Microsoft provides a Resource Kit tool for sleepready. 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 timeoutcommand.

application areas

The Windows Task Scheduler and Cron in UNIX use the sleepcommand to schedule processes or to delay their execution.

In a divided network , the sleepcommand limits the number of users who want to download a large file (e.g. with the Unix wget command ).

Individual evidence

  1. ^ Ibiblio: Package group Utilities. Retrieved September 18, 2018 .
  2. die.net: sleep (3): sleep for specified number of seconds - Linux man page. Retrieved September 18, 2018 .
  3. Gnu.org: GNU Coreutils: sleep invocation. Retrieved September 18, 2018 .
  4. ^ Microsoft : Start-Sleep. Retrieved September 18, 2018 .
  5. Microsoft : Download Windows Server 2003 Resource Kit Tools from Official Microsoft Download Center. Retrieved September 18, 2018 .
  6. Microsoft : Timeout Microsoft Docs. Retrieved September 18, 2018 .
  7. Groovy Post: Schedule Windows to Sleep and Wake Automatically. Retrieved September 18, 2018 .
  8. LazyDev: cron vs sleep which is better? Retrieved September 18, 2018 .

Web links