Unix Shell - cronjobs with errors in shell scripts

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > August 2007 > cronjobs with errors in shell scripts





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author cronjobs with errors in shell scripts
Navin

2007-08-25, 1:22 pm

hi,
I have a list of cronjobs.but they are generating errors. I don't
know how to debug those scripts. kindly please advice if anyone knows
how to debug the shell script with sample code

Thanks ,

Naveen

John L

2007-08-25, 1:22 pm


"Navin" <naveenjangiti@gmail.com> wrote in message news:1188056472.521179.8850@r23g2000prd.googlegroups.com...
> hi,
> I have a list of cronjobs.but they are generating errors. I don't
> know how to debug those scripts. kindly please advice if anyone knows
> how to debug the shell script with sample code
>


Check if there is a cron log, and also whether any output
has been sent by email to the user whose cron jobs these are.

If a shellscript works when run from the command line but
not as a cron job, often the problem is that environment
variables are set wrongly. Add the command env to
the shellscript, with its output redirected to a file somewhere.

--
John.


Miles

2007-08-27, 1:25 pm

On Aug 25, 10:41 am, Navin <naveenjang...@gmail.com> wrote:
> hi,
> I have a list of cronjobs.but they are generating errors. I don't
> know how to debug those scripts. kindly please advice if anyone knows
> how to debug the shell script with sample code
>
> Thanks ,
>
> Naveen


You can also create a wrapper. A script to run all your other scripts
(via cron). This script can capture all the output (standard out and
standard error). A far complicated solution, but once it is in place,
it is very nice.

Miles

Cyrus Kriticos

2007-08-27, 7:22 pm

Navin wrote:
>
> I have a list of cronjobs.but they are generating errors. I don't
> know how to debug those scripts. kindly please advice if anyone knows
> how to debug the shell script with sample code


If your scripts are bash scripts start them on the command line like this:

bash -x script

--
Best regards | "The only way to really learn scripting is to write
Cyrus | scripts." -- Advanced Bash-Scripting Guide
Cyrus Kriticos

2007-08-27, 7:22 pm

Navin wrote:
>
> I have a list of cronjobs.but they are generating errors. I don't
> know how to debug those scripts. kindly please advice if anyone knows
> how to debug the shell script with sample code


If your scripts are bash scripts start them on the command line like this:


bash -x script >errors.log 2>&1


and analyse its logfile error.log.

--
Best regards | "The only way to really learn scripting is to write
Cyrus | scripts." -- Advanced Bash-Scripting Guide
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com