Re: BSD sleep
On Tue, May 28, 2013 at 07:01:40PM -0400, Kenta Suzumoto wrote: # Hi. Is there no built-in way of making sleep sleep in increments # of minutes, hours, etc? The GNU sleep can be invoked like sleep # 1h for an hour. The FreeBSD one's manpage leads me to believe we # can only use seconds, which is kind of annoying. Is there an # undocmented or missing feature here? Seems really trivial to # implement. # # ~ $ sleep 1h # usage: sleep seconds Perfection is reached when there is nothing left to take away. The GNU format is already an incompatibility. If I want to sleep longer than 3 digit amount in secs, I do the math. The POSIXly *portable* way to do this and document it for the mathematically challenged is sleep $((2*60*60))# 2h sleep $((7*24*60*60)) # 1w Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
On 29/05/2013 05:59, Michael Sierchio wrote: On Tue, May 28, 2013 at 4:45 PM, Joshua Isom jri...@gmail.com wrote: You think it's trivial until you read this: http://infiniteundo.com/post/**25326999628/falsehoods-** programmers-believe-about-timehttp://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time Some days have 86400 seconds, some have 86401. There is a provision for two leap seconds to be applied at once, but that hasn't ever happened. Still, a truly correct clock, set to UTC, might someday read 23:59:59 23:59:60 23:59:61 00:00:00 How many seconds did that hour have? Right. The fact that on very rare occasions a minute may not have 60 seconds in it plus many other corner cases in calculating the current wall-clock time is an amusing irrelevance. First of all, sleep deals in local elapsed time, which is a well defined property even if the displayed wall-clock time would be all over the place due to DST changes or relativistic effects or whatever. In this case, I'd be pretty surprised if GNU sleep's algorithm was anything more complicated than to convert the stated time into seconds and then sleep that number of seconds. And to do that conversion, it wwould just define one minute as 60 seconds, one hour as 60 minutes, one day as 24 hours, one week as 7 days, perhaps one month as 30 days, one year as 365 days[*]. Sure, it's simplistic and unsophisticated, but as an engineering solution it's good enough for the vast majority of purposes. Cheers, Matthew [*] I haven't checked on GNU sleep, but (for example) this is exactly what dnssec-keygen(8) does. -- Dr Matthew J Seaman MA, D.Phil. PGP: http://www.infracaninophile.co.uk/pgpkey signature.asc Description: OpenPGP digital signature
Re: BSD sleep
On 05/29/13 05:59, Michael Sierchio wrote: On Tue, May 28, 2013 at 4:45 PM, Joshua Isom jri...@gmail.com wrote: You think it's trivial until you read this: http://infiniteundo.com/post/**25326999628/falsehoods-** programmers-believe-about-timehttp://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time Some days have 86400 seconds, some have 86401. There is a provision for two leap seconds to be applied at once, but that hasn't ever happened. A little pedantic nitpick: no there isn't, that was caused by an initial misreading of the definition of leap seconds. There *can* be two leap seconds in a year (which is what caused the confusion), but if that happens one will be at the end of June and the other at the end of December, they'll not happen together. Theoretically it's possible to have a negative leap second, but as that would require the Earth's core to collapse enough to spin it faster or a hit from a massive impactor, I'd rather not be around to see it. :-} -- In the dungeons of Mordor, Sauron bred Orcs with LOLcats to create a new race of servants. Called Uruk-Oh-Hai in the Black Speech, they were cruel and delighted in torturing spelling and grammar. _Lord of the Rings 2.0, the Web Edition_ ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
what is stopping from interpreting 1h in similar manner to 3600? i.e. from now No, this is user-friendly, and thus can't be done :) But if think a second, sleep is used rarely by average users, mostly by programmers and other scripts, and they should know better what they are doing. Seriously, that explanation about different hours is not enough to prevent at least useful option. like sleep -f 1h (-f means force convert, without it you can see good explanation why sleep for 1 hour will be not sleep for 1 hour, and etc, and not get sleep at all.). Exact units in which sleeps happens (seconds, ticks, minutes, years) can be described in manual page, even without accepting m,h - that info would be useful for one. P.S. There is already non-portable feature in sleep - non-integer, and I'm sure that no one thought about some financists from various countries, who used to specify long numbers with separator, e.g. 3.600, and this means for them one hour and not 3 point 6 seconds. -- Regards, Alexander Yerenkow ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
On 29 May 2013 07:13, Matthew Seaman matt...@freebsd.org wrote: On 29/05/2013 05:59, Michael Sierchio wrote: On Tue, May 28, 2013 at 4:45 PM, Joshua Isom jri...@gmail.com wrote: You think it's trivial until you read this: http://infiniteundo.com/post/**25326999628/falsehoods-** programmers-believe-about-time http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time Some days have 86400 seconds, some have 86401. There is a provision for two leap seconds to be applied at once, but that hasn't ever happened. Still, a truly correct clock, set to UTC, might someday read 23:59:59 23:59:60 23:59:61 00:00:00 How many seconds did that hour have? Right. The fact that on very rare occasions a minute may not have 60 seconds in it plus many other corner cases in calculating the current wall-clock time is an amusing irrelevance. First of all, sleep deals in local elapsed time, which is a well defined property even if the displayed wall-clock time would be all over the place due to DST changes or relativistic effects or whatever. In this case, I'd be pretty surprised if GNU sleep's algorithm was anything more complicated than to convert the stated time into seconds and then sleep that number of seconds. And to do that conversion, it wwould just define one minute as 60 seconds, one hour as 60 minutes, one day as 24 hours, one week as 7 days, perhaps one month as 30 days, one year as 365 days[*]. Sure, it's simplistic and unsophisticated, but as an engineering solution it's good enough for the vast majority of purposes. OK, but is this really something the OS should handle? I'm sure sleep `expr 3600 \* 2` will suffice and is perfectly readable, including being more portable. Why should we keep putting these weird extensions in? At some point it just becomes fiddling, and yet another source of error when porting Chris ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
Seriously, that explanation about different hours is not enough to prevent at least useful option. like sleep -f 1h (-f means force convert, without it you can see good explanation why sleep for 1 hour will be not sleep for 1 hour, and etc, and not get sleep at all.). Do one thing, and do it well. What you have proposed involves: * an additional force flag * interpolation of what follows the force flag (does m mean minutes, or months?) * expectations around time, time zones, and what an hours is. That fails the litmus test on complexity for me personally - it seems like a lot of complexity for not much gain. P.S. There is already non-portable feature in sleep - non-integer, and I'm sure that no one thought about some financists from various countries, who used to specify long numbers with separator, e.g. 3.600, and this means for them one hour and not 3 point 6 seconds. This isn't a good reason for adding another non-portable feature. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
I'm just saying that there's pretty space for discussion. If someone raised this now, why not discuss it now. If you sleep one hour, do you sleep one hour from now or one hour from the system clock which may change in the next hour? If it's the system clock, you may sleep for ten minutes or ten hours. If you need to sleep for 3600 seconds, that's simple and understandable. How about rephrase it: If you sleep 3600 seconds, do you sleep 3600 seconds from now or 3600 seconds from the system clock which may change in the next hour? If it's the system clock, you may sleep for ten minutes or ten hours. How way of specifying period changing the fact that internal minimal unit of sleep is not clearly specified in manpage? Also, there no info on how DST/ ntp time changes affects of running sleeps. I don't see right now how new flag (which currently if specified makes `sleep` exit with help), could break something, but I see that this is could be useful in some cases. This also raise question what sleep should do if something specified incorrectly, like sleep 2h30m30m , or 1h1h or else. And also if any changes would be accepted, this should be specified in manpage (that one about `m` as month). About non-portable feature with non-integers, it was just side observation. -- Regards, Alexander Yerenkow ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
On May 29, 2013, at 7:58 AM, Jason Birch jbi...@jbirch.net wrote: Seriously, that explanation about different hours is not enough to prevent at least useful option. like sleep -f 1h (-f means force convert, without it you can see good explanation why sleep for 1 hour will be not sleep for 1 hour, and etc, and not get sleep at all.). Do one thing, and do it well. What you have proposed involves: * an additional force flag * interpolation of what follows the force flag (does m mean minutes, or months?) * expectations around time, time zones, and what an hours is. That fails the litmus test on complexity for me personally - it seems like a lot of complexity for not much gain. Agreed. When I first started dealing with Unix professionally (1995, I started playing with Unix-like OSes almost 10 years earlier) I was taught that each Unix command does one thing and does it well. That simplicity is one of the core strengths of Unix (and Unix-like) OSes. With the popularization of Linux I see many movements towards a dumbing down of the OS, making it behave more like more common OSes, even if those changes make it less robust and flexible. One of the reasons I choose FreeBSD over Linux in many cases is that FreeBSD is closer to the roots of Unix in terms of keeping things simple and reliability being more important than convenience. Disclaimer: I spent most of my time between 1995 and 2012 managing Solaris systems. An occasional Linux system would crop up. When I started really looking at FreeBSD in 2012 (I wanted ZFS and OpenSolaris / OpenIndiana / NexentaCore / Illumos did not support my hardware) I was very happily surprised that it felt like a grown up OS and not the toy that many Linux distributions feel like to me. -- Paul Kraus Deputy Technical Director, LoneStarCon 3 Sound Coordinator, Schenectady Light Opera Company ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
On Wed, 29 May 2013 12:04:47 +0100 Chris Rees wrote: On 29 May 2013 07:13, Matthew Seaman matt...@freebsd.org wrote: Right. The fact that on very rare occasions a minute may not have 60 seconds in it plus many other corner cases in calculating the current wall-clock time is an amusing irrelevance. And in any case where you cared about the leap second, you would probably care that sleep doesn't wake-up on a second boundary, and can end-up in the next second. OK, but is this really something the OS should handle? I'm sure sleep `expr 3600 \* 2` will suffice and is perfectly readable, including being more portable. +1 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
On Wed, 29 May 2013 10:01:53 -0400 Paul Kraus wrote: Agreed. When I first started dealing with Unix professionally (1995, I started playing with Unix-like OSes almost 10 years earlier) I was taught that each Unix command does one thing and does it well. It would still just be doing one thing - sleeping. Support for units usually comes under and does it well. I wouldn't want to have to pipe df through awk to get MBs, or complicate find with arithmetic. Unit support in sleep is a perfectly legitimate thing to ask for, I don't think it particularly useful though, and leap-second support is close to pointless. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
I'm personally a fan of a forest-green bike shed myself... It would still just be doing one thing - sleeping. I agree. Perfect solution fallacy aside, a sleep option with basic time increments would be useful for real-world purposes. I'm in favor of computing it as a multiple of seconds as previously outlined. We don't need to contrive the sleep function for every possible corner case until it's reduced to something complicated, buggy and unreliable. As long as it doesn't break existing code, new and useful options are appreciated. As a programmer, if I say sleep for 1 hour I expect it to sleep for 3600 local seconds from the time the call is made until it wakes up again without any absurd gotchas. If the real-world time elapsed is more or less than 3600 seconds due to an internal clock error - fine. That's a different problem altogether. My 2 cents. -Modulok- On 5/29/13, RW rwmailli...@googlemail.com wrote: On Wed, 29 May 2013 10:01:53 -0400 Paul Kraus wrote: Agreed. When I first started dealing with Unix professionally (1995, I started playing with Unix-like OSes almost 10 years earlier) I was taught that each Unix command does one thing and does it well. It would still just be doing one thing - sleeping. Support for units usually comes under and does it well. I wouldn't want to have to pipe df through awk to get MBs, or complicate find with arithmetic. Unit support in sleep is a perfectly legitimate thing to ask for, I don't think it particularly useful though, and leap-second support is close to pointless. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
On Tue, 28 May 2013 at 19:01 -, Kenta Suzumoto wrote: Hi. Is there no built-in way of making sleep sleep in increments of minutes, hours, etc? The GNU sleep can be invoked like sleep 1h for an hour. The FreeBSD one's manpage leads me to believe we can only use seconds, which is kind of annoying. Is there an undocmented or missing feature here? Seems really trivial to implement. ~ $ sleep 1h usage: sleep seconds See also /usr/ports/misc/delay. Stuart ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
BSD sleep
Hi. Is there no built-in way of making sleep sleep in increments of minutes, hours, etc? The GNU sleep can be invoked like sleep 1h for an hour. The FreeBSD one's manpage leads me to believe we can only use seconds, which is kind of annoying. Is there an undocmented or missing feature here? Seems really trivial to implement. ~ $ sleep 1h usage: sleep seconds ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
On 5/28/2013 6:01 PM, Kenta Suzumoto wrote: Hi. Is there no built-in way of making sleep sleep in increments of minutes, hours, etc? The GNU sleep can be invoked like sleep 1h for an hour. The FreeBSD one's manpage leads me to believe we can only use seconds, which is kind of annoying. Is there an undocmented or missing feature here? Seems really trivial to implement. ~ $ sleep 1h usage: sleep seconds You think it's trivial until you read this: http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time If you sleep one hour, do you sleep one hour from now or one hour from the system clock which may change in the next hour? If it's the system clock, you may sleep for ten minutes or ten hours. If you need to sleep for 3600 seconds, that's simple and understandable. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
You think it's trivial until you read this: http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time If you sleep one hour, do you sleep one hour from now or one hour from the system clock which may change in the next hour? If it's the system clock, you may sleep for ten minutes or ten hours. If you need to sleep for 3600 seconds, that's simple and understandable. what is stopping from interpreting 1h in similar manner to 3600? i.e. from now ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: BSD sleep
On Tue, May 28, 2013 at 4:45 PM, Joshua Isom jri...@gmail.com wrote: You think it's trivial until you read this: http://infiniteundo.com/post/**25326999628/falsehoods-** programmers-believe-about-timehttp://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time Some days have 86400 seconds, some have 86401. There is a provision for two leap seconds to be applied at once, but that hasn't ever happened. Still, a truly correct clock, set to UTC, might someday read 23:59:59 23:59:60 23:59:61 00:00:00 How many seconds did that hour have? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org