How to debug cron job? 
Author Message
 How to debug cron job?

I have a Perl script that I'd like to run as a cron job.  The script
runs well if I run it myself, but it crashes when cron runs it.  How
can I debug this?  I'd like to use the Perl de{*filter*}, but I don't know
how to invoke the Perl de{*filter*} within on a job that will be run by
cron.

Thanks!

Fran



Tue, 19 Oct 2004 22:18:42 GMT  
 How to debug cron job?

Quote:

> I have a Perl script that I'd like to run as a cron job.  The script
> runs well if I run it myself, but it crashes when cron runs it.  How
> can I debug this?  I'd like to use the Perl de{*filter*}, but I don't know
> how to invoke the Perl de{*filter*} within on a job that will be run by
> cron.

> Thanks!

> Fran

Well you cant easily run a de{*filter*} since the cron job isn't attached to a
terminal.

I generally use print statements for debugging. Also you need to see what is
written to stderr as well as stdout.

As an example, I use the following to run my daily cron job. It uses nice to
lower the priority, copies stderr & stdout (the 2>&1 bit), and emails me the
results:

gtoomey



Tue, 19 Oct 2004 22:58:14 GMT  
 How to debug cron job?

Quote:

>The script
>runs well if I run it myself, but it crashes when cron runs it.  

What does "crashes" mean when you say it?

Does it make any output? Like error messages or anything?

Does in consume all of your memory?

Does it dump core?

Does smoke come out of the box?

Symptoms are important when you are hoping for a diagnosis.

Please give us some.

What have you observed that makes you think that it is "crashing"?

Quote:
>How
>can I debug this?  

The primary difference is the environment.

Use absolute paths to executables and data files.

Check the return values from open() et. al.

Insert print() statements.

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Tue, 19 Oct 2004 23:06:19 GMT  
 How to debug cron job?

Quote:

> I have a Perl script that I'd like to run as a cron job.  The script
> runs well if I run it myself, but it crashes when cron runs it.

How does it crash?  Does it start at all?  You don't state your OS but it may be
that your script's operation requires some of environment variables that are not
set up by cron's execution.  If you're on Unix, try using 'at' instead -- it copies
your environment settings and makes that part of the task's initialization.

HTH,
-BD



Tue, 19 Oct 2004 23:02:37 GMT  
 How to debug cron job?
On Fri, 3 May 2002 21:18:42 +0000 (UTC), Fran_Klein

Quote:

> I have a Perl script that I'd like to run as a cron job.  The script
> runs well if I run it myself, but it crashes when cron runs it.  How
> can I debug this?  I'd like to use the Perl de{*filter*}, but I don't
> know how to invoke the Perl de{*filter*} within on a job that will be
> run by cron.

You probably need to review your system's crontab(1) manual page.  In
particular, the current working directory and the value of the PATH
variable could be very different than your interactive shell's
environment.  

--
Garry Williams



Tue, 19 Oct 2004 23:24:29 GMT  
 How to debug cron job?

Quote:

> On Fri, 3 May 2002 21:18:42 +0000 (UTC), Fran_Klein

> > I have a Perl script that I'd like to run as a cron job.  The script
> > runs well if I run it myself, but it crashes when cron runs it.  How
> > can I debug this?  I'd like to use the Perl de{*filter*}, but I don't
> > know how to invoke the Perl de{*filter*} within on a job that will be
> > run by cron.

> You probably need to review your system's crontab(1) manual page.  In
> particular, the current working directory and the value of the PATH
> variable could be very different than your interactive shell's
> environment.

Lots of
print "$MYVAR";
in script will help.  The print statements will be sent via mail to
owner of cron job.


Sun, 24 Oct 2004 17:27:09 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Perl in cron jobs - output

2. oracle cron job

3. executing perl program in cron job

4. Difficulties running a Perl/tip job from cron

5. do 'functions.pl': problems with cron jobs

6. Newbie needs help with cron job

7. Cron Job limitations - help needed

8. Different results when a cron job

9. Get last execution time for a cron job

10. Running Perl Script as cron job : SERIOUS PROBLEM

11. LWP and Linux Cron Jobs?

12. Date Manipulation / Cron Job

 

 
Powered by phpBB® Forum Software