Re: Deterministic delays in POSIX shell scripts (Was: Re: notify via virtual terminal available packages)
On Fri 25 Sep 2020 at 12:28:31 (+0000), Andy Smith wrote:
> On Fri, Sep 25, 2020 at 07:49:19AM -0400, Greg Wooledge wrote:
> > On Fri, Sep 25, 2020 at 07:44:25AM +0000, Andy Smith wrote:
> > > "hostid" tends to return a hexadecimal representation of the first
> > > IPv4 address (but isn't guaranteed to).
> >
> > unicorn:~$ hostid
> > 007f0101
> >
> > Doesn't look very useful. That's just 127.0.1.1 in a 16-bit little
> > endian format.
>
> Oh, none of mine do that, it seems to pick the other IP address for
> me. But if it's a problem there are other sources of "machine" ID as
> I mentioned. There's some more here:
>
> http://0pointer.de/blog/projects/ids.html
IIRC Debian's recommendation is that a machine's own hosts entry
should be:
127.0.0.1 localhost
[…]
127.0.1.1 axis.corp axis # 192.168.1.14
(The comment at the end is there because I generate my hosts file
with a script that puts the 127.0.1.1 into place.)
That might explain the monotonous 007f0101. Perhaps you don't
set you hosts files that way.
> > You know what else works really well? Just putting a different start
> > time in each system's crontab.
>
> If that works for you, great, but I have quite a few machines, VMs
> and containers provisioned identically and would rather not have to
> change the scripts or configuration on a per-host basis.
I don't know what scaling you require, nor the time resolution you
can detect, but the last octet of the IPv4 address × 10 seconds
gives you delays of up to ~42 minutes, unique on what was once
called a "Class C" network. (15 seconds will go just over the hour.)
Cheers,
David.
Reply to: