@reboot /path/to/perl /path/to/bbtester start > /tmp/cron_bbtester.log
+ 2>&1
Regarding the use lib problem, there is a solution to allow the finding of libs regardless of where one runs the script from. Here's a simple module, that is located in the same directory the script is in (~/scratch/demo for this example):
package Module;
use warnings;
use strict;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(flail_around);
sub flail_around {
print "Flailing like a dying chicken!\n";
}
Here's the script. Note the use of $RealBin. That variable contains the directory where the script resides. It's equivalent to ., if one is actually within that directory:
use warnings;
use strict;
use FindBin qw($RealBin);
use lib $RealBin;
use Module qw(flail_around);
flail_around();
Output when I run the script from within that dir:
spek@scelia ~/scratch/demo $ perl script.pl
Flailing like a dying chicken!
Output if I run the script from somewhere else within the file system:
spek@scelia ~ $ perl scratch/demo/script.pl
Flailing like a dying chicken!
So it's very similar to use lib '.', but it uses the absolute path which is generated on the fly by looking up which directory the script is actually in. If your modules were in a lib/ dir within the directory, change use lib $RealBin; to use lib "$RealBin/lib";. |