From: "Shawn H Corey" <shawnhco...@gmail.com>
Subject: Re: Using perlbrew to change Perl version for scripts


On 12-06-03 03:01 AM, Octavian Rasnita wrote:
So for running cron jobs with a version of Perl installed by Perlbrew, I
just needed to add the following lines at the start of cron script:

PERL5LIB=/home/teddy/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2:/home/teddy/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2


PATH=/home/teddy/perl5/perlbrew/bin:/home/teddy/perl5/perlbrew/perls/perl-5.14.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin


That's all.

The advantage is that when you'll install a new version of Perl with
Perlbrew, you will just need to change 2 lines in cron, and not all the
Perl programs.

Which you have to do for every cron script. And you're not using perlbrew; you're bypassing it and doing one of its task manually. To use perlbrew in your cron scripts, replace the above two lines with:

# perlbrew
if [ -e /home/teddy/perl5/perlbrew/etc/bashrc ]
then
source /home/teddy/perl5/perlbrew/etc/bashrc
fi

Now, after you do a `perlbrew switch ...` the next time the cron script starts, it will use the new perl. Which is what using perlbrew means; the ability to change the perl version without changing all your scripts.





I tried that, but it gives an error:

"/tmp/crontab.YkxBxg/crontab":6: bad minute

the if [ ... ] line doesn't seem to be accepted in cron jobs.

So without this feature, yes, we might need to change a few chars in 2 lines in every cron script, but a user has only a single cron job so it is not such a big issue.

Octavian


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to