Sleep: invalid number '0.01'

I want to make a process sleep in bash script by using sleep 0.01. However, the system gives me sleep: invalid number '0.01' error. Is there a sleep version that can accept fraction times?
When I type sleep the output is: BusyBox v1.25.1 () multi-call binary.

The Linux manual implies that the interval is seconds only. Fruther, it seems the value may be programmed as an integer, hence whole numbers >0 would be required.

https://linux.die.net/man/3/sleep

But, the sleep in my laptop OS which is Ubuntu 16.04 works with fraction arguments with no problem.

busybox has usleep but it isn't enabled by default in openwrt.
Or
coreutils-sleep package which should support floating point numbers.
https://www.gnu.org/software/coreutils/manual/html_node/sleep-invocation.html

GNU sleep also accepts two or more arguments, unit suffixes, and floating-point numbers in either the current or the C locale.

But it will fail to install, I guess, because it will conflict with busybox sleep.

3 Likes

You can enable usleep for busybox if you build your own images.

No it does not conflict with BusyBox sleep. Now, it works with sleep of coreutils-sleep to accept float argument.

3 Likes

I'm glad it worked.

1 Like

BusyBox provides commands with symlinks to /bin/busybox.
Installing the full version package points the symlink to the new binary.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.