in reply to Re^6: Continuous or timed?
in thread Continuous or timed?

Agreed on all counts.

Here's an example crontab entry I've got on some of my Pi CI systems where I start a test listener program at reboot. It logs all the output to a dedicated file:

@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";.

Replies are listed 'Best First'.
Re^8: Continuous or timed?
by Bod (Parson) on Dec 14, 2020 at 17:30 UTC

    Thank you stevieb - that is really helpful and everything I needed to get the RPi controller working.

    There is still an updater to write but, now that the main part works, that should be relatively straightforward.