With the help of Linux sleep you can pause processes and let them run again af­ter­wards. The command works under Linux and in com­bi­na­tion with other commands and can be cus­tomized.

What is Linux sleep?

The Linux command sleep is used to pause a process for a specified period of time. How long this pause should last and whether operation is resumed or aborted af­ter­wards is up to the user’s dis­cre­tion. sleep is not only available in all common Linux dis­tri­b­u­tions like Debian or Ubuntu and doesn’t have to be installed sep­a­rate­ly, but there’s also an equiv­a­lent in other operating systems The sleep command is a simple and useful tool par­tic­u­lar­ly where shell scripts are to be paused.

How does the sleep command work?

The func­tion­al­i­ty of the Linux sleep command can be quickly explained. In addition to the actual command, you specify a duration and possibly a unit for the time. This is specified in seconds by default, but can also be added for minutes, hours or even days. The time value doesn’t have to be an integer, but can also be a floating point number. In this case, a point is used instead of a comma. Several sleep commands may be executed in suc­ces­sion. If you want to execute a sub­se­quent command, use an AND operation (“&&”). You’ll find an example of this below.

What is the syntax of the Linux sleep command?

The syntax of Linux sleep is as follows:

$ sleep [Number] [Suffix]
bash

sleep is always applied to the current process, unless you specify a different program.

What options and pa­ra­me­ters does Linux sleep have?

There are only two options for the sleep command: “-h” or “–help” for in­for­ma­tion about sleep and “-v” or “–version” for in­for­ma­tion about version, license and de­vel­op­ment. However, you can specify the time unit yourself. The allowed pa­ra­me­ters are:

  • s: The time is specified in seconds by default. When you omit the suffix, the numerical value will be cal­cu­lat­ed in seconds.
  • m: The time is specified in minutes.
  • h: The time is specified in hours.
  • d: The time is specified in days.

Examples of the Linux sleep command

Finally, to il­lus­trate how Linus sleep works, we’ll show you a few examples of how it’s used.

$ sleep 60
bash

The current process will be paused for one minute (60 seconds) and then will continue to run.

$ sleep 2.5h
bash

The command pauses the current process for two and a half hours.

$ sleep 2m && killall libreoffice
bash

In con­junc­tion with the Linux killall command, this ter­mi­nates the Li­bre­Of­fice program two minutes after executing sleep.

Go to Main Menu