LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-26-2006, 09:42 AM   #1
bowie101
Member
 
Registered: Nov 2005
Distribution: FC4 & RHES
Posts: 105

Rep: Reputation: 15
How to trouble shoot cron jobs ?


Newbie here asking a question on behalf of a non-newbie who is stuck :

On Red Hat Enterprise Server, the cron job isn't working. what / how do you suggest we troublshoot it? anyone know why it may not be working?

not working, as in, it won't run. If the script is run manually, it will run.
 
Old 01-26-2006, 10:48 AM   #2
bmeckle
Member
 
Registered: Jun 2004
Posts: 60

Rep: Reputation: 15
Check the permissions and make sure that the user is allowed to use cron. That would be the first place to start.
 
Old 01-26-2006, 11:27 AM   #3
bowie101
Member
 
Registered: Nov 2005
Distribution: FC4 & RHES
Posts: 105

Original Poster
Rep: Reputation: 15
logged in as root.

OK, here are the environmental variables, first :

Code:
TOMCAT_HOME=/srvrs/tomcat-5.5.7
HOSTNAME=foo1.foo2.foo3
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
CVSROOT=:ext:root@foo1.foo2.foo3:/srvrs/cvsroot
ANT_HOME=/usr/ant-1.6.2
USER=root
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
LD_LIBRARY_PATH=/home/oracle/OraHome1/lib:.
USERNAME=root
TNS_ADMIN=/home/oracle/OraHome1/nework/admin/tnsnames.ora
MAIL=/var/spool/mail/root
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/home/oracle/OraHome1/bin:/usr/java/jdk1.5.0_01/bin:/usr/ant-1.6.2/bin:/usr/local/pgsql/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin/X11:/usr/X11R6/bin:/root/bin
INPUTRC=/etc/inputrc
PWD=/home/production/perl/amp-stamp
JAVA_HOME=/usr/java/jdk1.5.0_01
LANG=en_US.UTF-8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
XERCESCROOT=/opt/xerces-c-src_2_5_0
SHLVL=1
HOME=/root
LD_ASSUME_KERNEL=2.4.19
BASH_ENV=/root/.bashrc
LOGNAME=root
CVS_RSH=/usr/bin/ssh
LC_CTYPE=en_US
LESSOPEN=|/usr/bin/lesspipe.sh %s
DISPLAY=localhost:10.0
ORACLE_HOME=/home/oracle/OraHome1
G_BROKEN_FILENAMES=1
XAUTHORITY=/root/.xauthuCQzMt
_=/bin/env
OLDPWD=/home/production/perl
-------------------------------------------------------------------------------------------
Here are the 2 scripts that won't run in cron :


1)

Code:
 
#!/bin/sh
 
cd /home/production/perl/amp-stamp
./loadnew >>amp-stamp.log

2)

Code:
 
#!/bin/sh
 
/home/production/ruby/guardcard/guardcardproto.rb
-----------------------------------------------------------------------------------------

and here's the error message that was emailed to root :

Code:
 
error  message by email as follow:    From root@foo1.foo2.foo3  Thu Jan 26 10:24:01 2006  Date: Thu, 26 Jan 2006 10:24:01 -0500  From: root@dfoo1.foo2.foo3 (Cron Daemon)  To: root@foo1.foo2.foo3 

Subject: Cron <root@foo1>  /home/production/perl/amp-stamp/loadplans.sh  X-Cron-Env: <SHELL=/bin/sh>  X-Cron-Env: <HOME=/root>  X-Cron-Env: <PATH=/usr/bin:/bin>  X-Cron-Env: <LOGNAME=root>     DBI connect('OG,'DS',...) failed: ERROR  OCIEnvNlsCreate (check ORACLE_HOME and NLS settings  etc.) at ./loadnew line  9  

Can't call method "prepare" on an undefined value at  ./loadnew line 10.         

 From root@foo1.foo2.foo3  

Thu Jan 26 10:40:00 2006  Date: Thu, 26 Jan 2006 10:40:00 -0500  From: root@foo1.foo2.foo3 (Cron Daemon)  To: root@foo1.foo2.foo3  Subject: Cron <root@foo1> /root/runscript.sh  X-Cron-Env: <SHELL=/bin/sh>  X-Cron-Env: <HOME=/root>  X-Cron-Env: <PATH=/usr/bin:/bin>  X-Cron-Env: <LOGNAME=root>     

Error code  

Error Message ERROR
---------------------------------------------------------------------

like i said, if it is run manually, it works.
 
Old 01-26-2006, 11:34 AM   #4
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,508
Blog Entries: 2

Rep: Reputation: 68
Pay attention to the first error message that shows in the e-mailed message. it says: check ORACLE_HOME. cron jobs not run with all environmental variables set. Check the manual page about this. As a workaround you may set ORACLE_HOME=/home/oracle/OraHome1 at the beginning of your scripts. Others variables may be need too. Check one at time. regards,

As a rule-of-thumb, shell scripts, including those that run by cron, must do not rely on any external dependencies , including those are set in rc scripts as .basrc or whatever.
They must be self-contained as much is possible, as this increase the security.
They also not be overloaded with unnecessary settings, like prompt, history, ,PATH, LD_LIBRARY_PATH with paths not used by that specific script/application.
Is a big mistake doing something like that at the beginning of yours scripts: ". ~/.basrc" to force the setting of all environmental variables you have in a interactive session. Please, don't do that, ever.

Last edited by marozsas; 01-26-2006 at 11:49 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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron Jobs XaViaR Linux - General 1 06-23-2005 06:57 PM
cron jobs working2hard Linux - Software 0 07-28-2004 05:31 PM
How do I trouble shoot slow performance? mrkirkland Linux - Laptop and Netbook 2 04-02-2004 10:32 AM
CRON Jobs scottpioso Linux - Software 63 11-28-2003 06:45 PM
trouble shoot sound problem shanenin Slackware 3 10-14-2003 04:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:02 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
Open Source Consulting | Domain Registration