LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-20-2006, 10:12 AM   #1
meshach
LQ Newbie
 
Registered: Dec 2005
Distribution: Slackware
Posts: 9

Rep: Reputation: 0
Errors when running Perl script in a cron job


I have a Perl script that uses several pm files like XMP/RSS.pm. I can run these scripts just fine and root can run them fine but when I put them in a cron job they fail to run. Examining the log file, the error is that the file XML/RSS.pm cannot be found.

My question is what user do cron jobs run as? Is there a way to add the @INC file string to that user so that the scripts can run properly? Or am I doing something else wrong?

Thanks,
Caleb
 
Old 06-20-2006, 02:53 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Cron runs as the user who owns the cron file. Presumably you're talking about the root cron so it runs as root.

However cron runs a minimal environment. It does NOT invoke .profile, .bashrc or other config files that you do when you login. When you run a command from the command line it inherits the environment from these config files that you had when you logged in. However the cron has nothing to inherit because of the minimal environment it runs.

Therefore the key is to insure that any varaible (PATH being the most common one) that is set when you are logged in needs to be added to your environment within the script itself. Alternatively you can speicify full paths to items. So where in a command line script you might just say "ls -l" in the cron script you need to have "/bin/ls -l" so it will know ls is in /bin.
 
Old 06-20-2006, 09:10 PM   #3
meshach
LQ Newbie
 
Registered: Dec 2005
Distribution: Slackware
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks jlightner, that was the fix I needed.
 
  


Reply



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
Cron Job not running ssh script karim0028 Linux - General 3 02-07-2005 12:08 PM
Trouble with perl script in Cron job thack111 Linux - General 7 11-25-2004 02:44 AM
script not running as a cron job sanjith11 Programming 5 11-23-2004 08:42 AM
log cron job to capture errors if there are ashley75 Linux - General 1 05-21-2004 10:34 AM
cron job errors existo Slackware 4 01-23-2004 02:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:07 AM.

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
Open Source Consulting | Domain Registration