LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-05-2011, 06:00 AM   #1
muzammil18
LQ Newbie
 
Registered: Jul 2011
Posts: 3

Rep: Reputation: Disabled
Perl Modules Spreadsheet::WriteExcel not working in Cron


Hello All

I have installed CPAN module Spreadsheet::WriteExcel, to generate some reports. Now when i execute my perl module from command line. it works fine and generates the excel file. When i put this module to be executed via cron, it doenst work and an email is generated. My entry in cron tab is as follows:

2 14 * * * perl /scripts/postpaidRecon/postpaid.pl

The email i receive in /var/spool/mail/root for module failure is:

Subject: Cron <root@kblhpw101> perl /scripts/postpaidRecon/postpaid.pl
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <20110705093201.66177C047@kblhpw101.localdomain>
Date: Tue, 5 Jul 2011 14:02:01 +0430 (AFT)

Can't locate Spreadsheet/WriteExcel.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/
5.8.8 /usr/lib/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/l
ib/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at /scrip
ts/postpaidRecon/postpaid.pl line 12.
BEGIN failed--compilation aborted at /scripts/postpaidRecon/postpaid.pl line 12.
 
Old 07-05-2011, 07:11 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
1. don't run as root, run as yourself
2. cron has a minimal default env setup (see the PATH definition shown). You may need to ensure cron runs your .bash_profile or any other login setup you have.
 
Old 07-05-2011, 07:14 AM   #3
muzammil18
LQ Newbie
 
Registered: Jul 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
I am the root.
Regarding second point, being a newbie i couldnt really get it. can you please elaborate it a bit more?

Thanks
 
Old 07-05-2011, 10:42 AM   #4
muzammil18
LQ Newbie
 
Registered: Jul 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks all, I found the solution.
Sometimes when modules dont work in cron (when they do in command line), just do the following

extract the module to a path of your choice (which is accessible by user). Lets say I am user george so i extracted the module to
/home/george/modules

now in your perl script simply put in the following line at the top

use lib '/home/george/modules/lib';

now it will work with cron.

Last edited by muzammil18; 07-05-2011 at 11:30 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
system froze when I clicked Save for Calc spreadsheet, now the spreadsheet is gone Stringdude Linux - Newbie 2 11-24-2010 02:05 AM
I got switched from a word process doc. into spreadsheet form. now ALL is spreadsheet 293 manzanita Linux - Newbie 1 08-04-2010 02:14 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 09:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U Suse/Novell 11 01-04-2007 02:57 AM
installing perl modules for Linbock is not working Hockeyfan Linux - Security 3 12-14-2005 01:17 PM


All times are GMT -5. The time now is 06:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration