
Hi,
I made up a new type of ticket number,
it is composed this way: year.month.day.Counter
The Counter must reset to zero every midnight, so I added a cron to the
crontab.
But my problem is:
What happend if someone store a new ticket at 23:59:59 of 11/12/02
and it takes to form the ticket number this date.
The cron runs at 00 of 12/12/02. and the Counter is taken after the cron
changes it to 0 then i'll have the ticket number 20021211001, and not the
last ticket of 20021211.
Its a litle confused.
There is a critical region between the program takes the date until the
program takes the counter. So the file where the Counter is saved, must be
blocked inside that critical region. And the cron, must retry if the file
is blocked.
Here are the files
I create
/opt/OpenTRS/var/log/cero.log with 0
I create
/opt/OpenTRS/var/cron/reset/reset_ticket_counter (look botom of this mail)
#crontab -e -u otrs
:1000 #to go to the end of th file.
:r /opt/OpenTRS/var/cron/reset/reset_ticket_counter
:wq
# --
# Ticket/Number/DateCounter.pm - a date ticket number generator
# Copyright (C) 2002 Diego Fernandez

Hi Diego, On Thu, Dec 12, 2002 at 04:16:03PM -0300, Diego Fernandez wrote:
I made up a new type of ticket number, it is composed this way: year.month.day.Counter The Counter must reset to zero every midnight, so I added a cron to the crontab. But my problem is: What happend if someone store a new ticket at 23:59:59 of 11/12/02 and it takes to form the ticket number this date. The cron runs at 00 of 12/12/02. and the Counter is taken after the cron changes it to 0 then i'll have the ticket number 20021211001, and not the last ticket of 20021211. [...]
It's easier if you take Ticket/Number/DateChecksum.pm as sample (remove just the checksum stuff). -=> The CounterLog incl. the last modify date (like "counter;date;"). If the date is not the same, the counter starts from 0. Like you want. No cronjob is needed! ,-)
Diego.
Martin -- Martin Edenhofer - <martin at edenhofer.de> - http://martin.edenhofer.de/ -- Old programmers never die. They just branch to a new address.
participants (2)
-
Diego Fernandez
-
Martin Edenhofer