in reply to A relative cron questions

Someone else please let me know if this is right, but my understanding was that you w/could do something like the following in a crontab(5) for such a thing:

DBUILDER_DIR=/home/indy/source/dbuilder * */6 * * * $DBUILDER_DIR/scripts/spamburglar.pl

To my knowledge, you don't have to put an environment variable definition in a cron entry on the same line, but can put it above entries if it affects more than one, or is more readable that way. Then, in your code, I am thinking you w/could do something like:

unless (defined($ENV{'DBUILDER_DIR'})) { $ENV{'DBUILDER_DIR'} = '..'; } use lib "$ENV{'DBUILDER_DIR'}/lib";

I haven't used the use lib... pragma you are using before, but I hope this either proves helpful in itself, or results in a more knowledgable monk posting to correct my misunderstanding, enlightening us both. My best in your quest for this knowledge.

Replies are listed 'Best First'.
Re: Re: A relative cron questions
by belg4mit (Prior) on Dec 11, 2001 at 20:42 UTC
    You can have environment variables per job, but there ought to be a semi-colon in there
    * */6 * * * DBUILDER_DIR=/home/indy/source/dbuilder;$DBUILDER_DIR/spam +burglar.pl
    If it on a non-job line it becomes available to all jobs.

    --
    perl -p -e "s/(?:\w);([st])/'\$1/mg"