[prog] Perl from cron

Kathryn Andersen kat_lists at katspace.homelinux.org
Thu Jun 23 07:13:11 EST 2005


On Wed, Jun 22, 2005 at 12:28:14PM -0700, jennyw wrote:
> Short story: I'm having trouble with a Perl script running from cron -- 
> it works great from a regular login shell, but in cron there are issues. 

Well, I don't know what the specific problem might be with FindBin, but 
one thing that happens frequently when one has a program or script which
works fine in a regular login shell, but doesn't work in cron is that
the environment is different.  In your login shell, various environment
variables have been set (first in a global /etc/bashrc file (for
example) and then from .*rc files in your home directory).  But cron
does not do this; its environment is the bare minimum.  That's why, when
you see examples of a crontab, you see the commands being given as
full-path commands -- because the PATH environment variable isn't
guaranteed to be there.

I suggest you write yourself a little script which does two things:
a) it contains the offending bits of code which are behaving
differently; like, print out the value of $RealBin after it's supposed
to be initialized.

b) prints out the environment.

That might help you track down what the problem is.

If it *is* in the environment, you could then change the line in your
crontab to set the offending variable explicitly, in the same line that
the required command is called.

OFFENDING_VAR=value /path/to/command

Actually... I also have a suspicion which variable it is: the PATH
variable mentioned above.  Because doesn't FindBin use PATH in order to
do its thing?

Kathryn Andersen
-=-=-=-=-=-=-=-=-
"He who trusts in his own mind is a fool;
but he who walks in wisdom will be delivered."	Proverbs 28:26
-- 
 _--_|\     | Kathryn Andersen	<http://www.katspace.com>
/      \    | 
\_.--.*/    | GenFicCrit mailing list <http://www.katspace.com/gen_fic_crit/>
      v     | 
------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
Maranatha!  |	-> Earth -> Sol -> Milky Way Galaxy -> Universe


More information about the Programming mailing list