Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CRON JOB QUESTION



On Tuesday 19 August 2003 01:25 pm, Gregory Boyce wrote:
> On Tue, 2003-08-19 at 17:38, Eric Schwartz wrote:
> > HELLO ALL,
> > 	I have a slight problem I hope you guys can help.  I have a scheduled
> > cron job to run a perl script that I have written.  It runs the
> > scheduled perl script at the right time, but the perl script is supposed
> > to output a file when it is run, and when I run the script with cron, no
> > file is output, but if i run the script by itself then it outputs the
> > file.  Any help would be appreciated, if you guys want to see any bits
> > from the perl script or cron, or have any questions please let me konw. 
> > Thanks again you guys are always a great help.
> 
> When you specified the output file, did you use an absolute or relative
> path?  Alternately, do you call any binaries from your perl script by a
> relative path?  One common problem I've seen is that people make
> assumptions on what the current working directory or the PATH statements
> are for cron.
> 
> Try /home/yourname/filename instead of filename for example.

Two more gotchas to look out for:

- When you are running it by hand as a test, make sure you are running it from 
a login shell (ie "su - username", not just "su username") of the same user 
as the crontab file you are putting it in.

- When you run a program from cron, it does not have all the environment 
variables set up that the same user would have logged in.  That includes 
$EDITOR, $PATH, etc.  So you need to either set environment variables you 
need, or don't need them.  That means any programs your Perl script calls 
will need absolute paths too, or you can set the $PATH before running it.

-------------------------------------------------------------------
DDDD   David Kramer                           http://thekramers.net
DK KD  
DKK D  "There are things that are so serious that you can only 
DK KD  joke about them."
DDDD                                                    -Heisenberg 




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org