Koha::Script - Koha scripts base class


    use Koha::Script
    use Koha::Script -cron;


This class should be used in all scripts. It sets the interface and userenv appropriately.


Class methods


    my $script = Koha::Script->new(
            script    => $0, # mandatory
          [ lock_name => 'my_script' ]

Create a new Koha::Script object. The script parameter is mandatory, and will usually be passed $0 in the caller script. The lock_name parameter is optional, and is used to generate the lock file if passed.


    # die if cannot get the lock
    try {
    catch {
        die "$_";

    # wait for the lock to be released
    $script->lock_exec({ wait => 1 });

This method sets an execution lock to prevent concurrent execution of the caller script. If passed the wait parameter with a true value, it will make the caller wait until it can be granted the lock (flock's LOCK_NB behaviour). It will otherwise throw an exception immediately.

Internal methods



This method initializes the locking configuration.


Martin Renvoize <martin.renvoize@ptfs-europe.com>