[Freeswitch-users] FreeSWITCH load CDR CSV to Mysql, theoretical problem?
Michael Jerris
mike at jerris.com
Thu Jan 26 16:04:14 MSK 2012
http://search.cpan.org/dist/Proc-Pidfile/Pidfile.pm
On Jan 25, 2012, at 2:06 PM, Paul Cupis wrote:
> On 25/01/12 13:25, Henrik Aagaard Sørensen wrote:
>> What if the job suddenly takes more than 5 minutes to complete and
>> another job start, doing the same thing.
>>
>> Couldn't that be a problem and can it be fixed?
>
> Use Perls Fcntl module to ensure the program can only be running once -
> if a second instance starts it will quit immediately and the next
> scheduled run will pick up the remaining files.
>
> Of course, if this happens to often you will take a long time to catch
> up with the importing.
>
> At the beginning of the script (after 'use File::Copy;') add:
>
>
> use Fcntl qw(:flock);
> unless (flock(DATA, LOCK_EX|LOCK_NB)) {
> exit;
> print "$0 is already running. Exiting.\n";
> exit(1);
> }
>
>
> and at the very end add:
>
> __DATA__
> This exists so flock() code above works.
> DO NOT REMOVE THIS DATA SECTION.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120126/a436de81/attachment.html
Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users
mailing list