Sep-01-2019, 06:38 PM
i hate when a sleep loop gradually creeps off time. doing sleep 60 doesn't synchronize to the minute, for example. my plan is to write a new sleep command in python that can.
used like the old sleep command it will work the same old way. with a 2nd argument added, it will synchronize to the period specified by the 2nd number, with the 1st number, which must not be larger than the 2nd, being an offset into the period of the 2nd, so "sleep 15 60" would sleep until the next cycle of 15 seconds past a minute. so if the current time is 9:13:04.000 it will sleep for 9 seconds. that way it can be used in a loop intended to run a command every minute at 15 seconds after the minute.
another thing i want it to do is accept times to sleep to. so "sleep 10:05" will sleep until the next "10:05", however long that happens to be. whether it works in 12 hour mode or 24 hour mode might need an environment variable setting, an option, or an obvious time.
used like the old sleep command it will work the same old way. with a 2nd argument added, it will synchronize to the period specified by the 2nd number, with the 1st number, which must not be larger than the 2nd, being an offset into the period of the 2nd, so "sleep 15 60" would sleep until the next cycle of 15 seconds past a minute. so if the current time is 9:13:04.000 it will sleep for 9 seconds. that way it can be used in a loop intended to run a command every minute at 15 seconds after the minute.
another thing i want it to do is accept times to sleep to. so "sleep 10:05" will sleep until the next "10:05", however long that happens to be. whether it works in 12 hour mode or 24 hour mode might need an environment variable setting, an option, or an obvious time.