[lug] Fwd: Simple counter?

Anthony Foiani tkil at scrye.com
Sat May 25 12:33:26 MDT 2013

"Jeffrey S. Haemer" <jeffrey.haemer at gmail.com> writes:

> Sure. We're using SQL now to do it.
> And if I'm going to roll my own, my options are legion. For example, as
> an SCM guy I know that SVN atomically numbers commits, so I could even
> use Subversion version numbering.
> "When all you have is a hammer ...."
> Of course, I'd have to be deeply disturbed to implement something like
> that (code follows), though it would work across users, reboots, and,
> with a little tweaking, over Teh Internets.

Heh.  You're one sick puppy.  I like that about you.

(Although I suspect that if you dig down deep enough, you'll find that
the svn server is fundamentally doing file locking pretty much the
same way that counter.c is doing it.)

For that matter, one could probably put 'counter' behind xinetd and
have a network service that would provide the unique values.  (I
should have written "ssh counter" in my original post on the subject,

After that, the only further step is high availability.  If I had to
do that, I'd probably request that the sequentiality requirement be
dropped, and assign disjoint ranges of numbers to all the hosts
running the 'counter' service.  At that point, though, one might be
better off with sufficiently large random values.

> But I'm in search of a single, simple, *existing* Linux command.

I think that Davide hit the nail on the head: if it's for a single
use, then it's trivial; if it's for general use, it's so unwieldy that
it'd go unused.

To put it differently, your one use case might seem simple to you; but
(as this thread has aptly demonstrated), it's probably not as simple
as we would like.


More information about the LUG mailing list