Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can run this command fine from the SSH console of my rackservers shared hosting:

cd /home/myaccount/public_html/whatever; perl -w 

But when I enter the same command as a cron job, I get:

Can't locate XML/ in @INC (@INC contains: /home/myaccount/public_html/whatever /usr/local/lib/perl5/5.8.8/x86_64-linux /usr/local/lib/perl5/5.8.8 /usr/local/lib/perl5/site_perl/5.8.8/x86_64-linux /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl . .) at line 21. BEGIN failed--compilation aborted at line 21.

Despite the fact that is sitting right next to it in the same directory (/home/myaccount/public_html/whatever), and it's got that path in the @INC, and I've done a cd to the correct folder just in case, it still whinges.

Bearing in mind it's on shared hosting so I can't change global settings, how can I convince perl to look for in /home/myaccount/public_html/whatever ?

Not sure it's relevant, but here's

ramruma suggested turning this into a shell script (below). I include my attempt here because comments can't be multiline:

cd $HOME/public_html/whatever
perl -w -I$HOME/public_html/whatever

Despite adding the folder to PERL5LIB, PATH, and @INC, this shell script doesn't even work from the SSH console. So if we can get this shell script working, I reckon we'll have the problem solved.

share|improve this question
While the mechanics of bash appear to be eluding me today, I don't think that's the crux of the issue. As you can see in the error message, we're already succeeding at getting the path in @INC. Why then isn't it picking it up? – harvest316 May 27 '12 at 11:05
News flash: perl -MXML::RSS -e'print $XML::RSS::VERSION' works fine from the console, where @INC doesnt have $HOME/public_html/whatever folder in it. So maybe it's nothing at all to do with include paths. – harvest316 May 27 '12 at 11:20
The ; in PATH should be a : and is perl really in /usr/local/bin as at the top of – ramruma May 27 '12 at 12:16

Write a shellscript that runs the command after setting any appropriate environment variables.

share|improve this answer
I might need some help making said shell script, ramruma. My attempt (above) didn't work. – harvest316 May 27 '12 at 10:46

you can add the local dir to the PERL5LIB environment variable at the top of your cron script like so;


52 * * * *  /usr/bin/perl -w -I/home/myaccount/public_html/whatever/
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.