From 2c6546d7f81a830cf0a1f5c16bb7c8746731e0c2 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 29 Mar 2015 18:00:42 +0200 Subject: [PATCH] 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. --- lib/perl/BEX/Job.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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; -- 2.39.5