'"sleep 5" doesn't delay script for five seconds [closed]

When I use the sleep command and execute the script the sleep doesn't work. The code just gets executed without stopping for the expected 5 seconds. I've added big values for after sleep too but it doesn't work.

#!/bin/bash
echo "Hello World"
sleep 5
echo "How Are you?"

I also ran bash -x script.sh:

+ echo 'Hello World'
Hello World
+ sleep 5
+ echo 'How Are you?'
How Are you?

Also ran strace -o script.trace -f bash -x script.sh. Here's script.trace file's data.

26    execve("/usr/bin/bash", ["bash", "-x", "script.sh"], 0x7fffcced70e8 /* 22 vars */) = 0
26    brk(NULL)                         = 0x7ffff5843000
26    access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
26    openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
26    newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=20067, ...}, AT_EMPTY_PATH) = 0
26    mmap(NULL, 20067, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f04111d4000
26    close(3)                          = 0
26    openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libtinfo.so.6", O_RDONLY|O_CLOEXEC) = 3
26    read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
26    newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=199992, ...}, AT_EMPTY_PATH) = 0
26    mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0411190000
26    mmap(NULL, 203072, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f0411150000
26    mmap(0x7f041115e000, 69632, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe000) = 0x7f041115e000
26    mmap(0x7f041116f000, 57344, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1f000) = 0x7f041116f000
26    mmap(0x7f041117d000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2c000) = 0x7f041117d0>26    close(3)                          = 0
26    openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
26    read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
26    newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=22864, ...}, AT_EMPTY_PATH) = 0
26    mmap(NULL, 24816, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f0411140000
26    mmap(0x7f0411142000, 8192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f0411142000
26    mmap(0x7f0411144000, 4096, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7f0411144000
26    mmap(0x7f0411145000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7f0411145000
26    close(3)                          = 0
26    openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
26    read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@y\2\0\0\0\0\0"..., 832) = 832

I'm using Kali Linux on WSL. What's wrong? How do I fix it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source