I know how to use sleep 5m for 5 minutes.

How would I use it for say 7 mins 30 seconds?


From the manpage:

Given two or more arguments, pause for the amount of time specified by the sum of their values.


sleep 7m 30s
  • 4
    Might be worth noting that this is bash built-in and GNU sleep behavior. POSIXly, sleep is only required to understand integers as seconds – Sergiy Kolodyazhnyy Aug 13 '18 at 1:46

Another way to do this is:

sleep 7.5m

man sleep

Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number.


There are two excellent answers already but I'd like to expand a bit. Copy and paste command below into your terminal:

$ sleep 3d 5h 7m 30.05s &
[1] 7321

This will start a second process that will sleep for 3 days, 5 hours, 7 minutes and 30.05 seconds. The process ID (PID) is 7321 in my case.

To confirm the PID use

$ ps aux | grep sleep
rick      7321  0.0  0.0  14356   660 pts/2    S    22:40   0:00 sleep 3d 5h 7m 30.05s
root     12415  0.0  0.0  14356   700 ?        S    22:41   0:00 sleep 60
rick     12500  0.0  0.0  21292   968 pts/2    R+   22:41   0:00 grep --color=auto sleep

The first entry is the one we are interested in. The second entry is for a permanent program I have running in startup. The third entry is for the grep command itself.

Now to see how much time is remaining (in seconds) for the sleep command generated by PID 7321 we can use this: How to determine the amount of time left in a “sleep”? command:

$ remaining_sleep_time 7321
$ remaining_sleep_time 7321
$ remaining_sleep_time 7321

The code for the command you can include in your ~/.bashrc file:

remaining_sleep_time() { # arg: pid
  ps -o etime= -o args= -p "$1" | perl -MPOSIX -lane '
    %map = qw(d 86400 h 3600 m 60 s 1);
    $F[0] =~ /(\d+-)?(\d+:)?(\d+):(\d+)/;
    $t = -($4+60*($3+60*($2+24*$1)));
    for (@F[2..$#F]) {
      ($n, $p) = strtod($_);
      $n *= $map{substr($_, -$p)} if $p;
      $t += $n
    print $t'
  • My remaining time is not working. andy@7_~$ remaining_sleep_time 7321 remaining_sleep_time: command not found – fixit7 Aug 12 '18 at 5:39
  • 1
    @fixit7 remaining_sleep_time needs to be copied into your ~/.bashrc file as per the link. You could also put the code into a bash script file. – WinEunuuchs2Unix Aug 12 '18 at 5:41

Command sleep is always counting in seconds. You could use ((7x60)+30) seconds and then type simply:

sleep 450

  • 3
    As noted previously , sleep indeed always understands seconds, but in case of GNU sleep and Bash shell ( not sure about ksh and zsh ) - those also allow letter arguments as noted in other answers. Your answer could be improved with using shell arithmetic expansion, so something like sleep $((60*7)) could be used for minutes – Sergiy Kolodyazhnyy Aug 14 '18 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.