Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Generate a unique ID

by JavaFan (Canon)
on Nov 15, 2010 at 10:05 UTC ( #871429=note: print w/ replies, xml ) Need Help??


in reply to Generate a unique ID

I'm looking to generate a unique ID for a given run of a program, that will distinguish it from any other--previous, subsequent or concurrent--run of that program on that same system.
A counter seems like the most obvious choice. Since you all you care about is processes on a single system, keeping the counter in a file will work. Otherwise, I'd use a database, or a small CGI program to hand out counters.
I'm thinking to combine: process id with current date-time to the highest resolution available. Is that enough?
In practice, on an OS that assigns PIDs increasingly (wrapping around when a limit has reached), yes. In theory, you have a clash. And if you don't do the "date/time" properly, you'll have a potential problem around daylight saving times change-over.


Comment on Re: Generate a unique ID

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://871429]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2015-07-06 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls