gimmeamilk gimmeamilk - 1 year ago 112
Linux Question

How can I generate system-wide unique IDs under Linux

I'm working on a multiprocess Linux system and need to generate unique IDs. Security is not a consideration, so an ID generator that starts at zero and counts up would be fine. Also it's just within a local machine, no network involved. Obviously it's not hard to implement this, but I was just wondering if there was anything already provided (preferably lightweight).

Answer Source

This sounds like a job for... ...uuidgen:

% uuidgen 

If you want to build it into your own application or service, you'll need libuuid:

#include <uuid/uuid.h>
#include <iostream>

int main()
    uuid_t uu;
    char uuid[37];
    uuid_unparse(uu, uuid);
    std::cout << uuid << std::endl;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download