Is 'sleep' based on the system clock or on time elapsed?
For example, if you execute:
And immediately suspend your system for 10 minutes, will it end in another 10 minutes, or will it continue to wait for the full 20 minutes?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Well I guess it was easy enough to test. After initiating a 5 minute sleep, I suspended the system for about 2 minutes. The answer?
Sleep is calculated using elapsed time of the process, not clock time.
date; sleep 300; date Tue Jul 2 20:58:41 EDT 2019 Tue Jul 2 21:05:28 EDT 2019
This may have been predictable since man sleep(3) says:
System activity may lengthen the sleep by an indeterminate amount.
Which kind of implies the amount of time is internal to the sleep process.