From: Martin Mares Date: Sun, 29 Mar 2015 16:00:42 +0000 (+0200) Subject: New format of job IDs X-Git-Tag: v3.3~3 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=2c6546d7f81a830cf0a1f5c16bb7c8746731e0c2;p=bex.git New format of job IDs Switched to "YYYYMMDD-HHMM-hash", where "hash" consists of 8 hex digits obtained by hashing the current time, PID and a sequence number. --- diff --git a/lib/perl/BEX/Job.pm b/lib/perl/BEX/Job.pm index 986028e..62d076d 100644 --- a/lib/perl/BEX/Job.pm +++ b/lib/perl/BEX/Job.pm @@ -1,5 +1,5 @@ # Batch EXecutor -- Jobs -# (c) 2011-2013 Martin Mares +# (c) 2011-2015 Martin Mares use strict; use warnings; @@ -7,6 +7,7 @@ use warnings; package BEX::Job; use POSIX (); +use Digest::SHA; our $job_cnt = 0; @@ -24,7 +25,9 @@ sub new($;$) { $job->{'ID'} = $id; } else { $job_cnt++; - $job->{'ID'} = POSIX::strftime("%Y%m%d-%H%M%S-$$-$job_cnt", localtime); + my $dt = POSIX::strftime("%Y%m%d-%H%M%S", localtime); + my $hash = Digest::SHA::sha1_hex(join(":", $dt, $$, $job_cnt)); + $job->{'ID'} = $dt . '-' . substr($hash, 0, 8); } $job->{'Subject'} = ''; return $job;