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 - 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-08-2007, 06:01 AM   #1
jonnynoh
LQ Newbie
 
Registered: Jan 2007
Posts: 3

Rep: Reputation: 0
Cron Issue on RHEL AS r4 Update 2


Hi all,
I hope someone can help me. I have a scirpt that does not seem to be running via cron. It's basically something written by one of our developers to export some Oracle databases every night. It runs fine from the command line but does not work via cron.

The script:
[root@localhost script]# ls -al secfin
-rwxr-xr-x 1 oracle oracle 259 Dec 5 17:48 secfin

#!/bin/sh
logfile="secfin`date +%a%b%d`.log"
dmp="secfin`date +%a%b%d`.dmp"
path=/home/oracle/backup/secfin/

echo $path
echo $dmp
echo $path

exp system/manager@secfin FULL=Y file=/home/oracle/backup/secfin/"$dmp" log=/home/oracle/backup/secfin/"$logfile"

The crontab:
[root@localhost ~]# crontab -u oracle -l
30 0 * * 1-5 /home/oracle/backup/script/secfin

So if I su to oracle and cd to /home/oracle/backup/script followed by ./secfin it works fine but via cron no joy.

The cron log shows:

Dec 28 00:30:01 localhost crond[19465]: (oracle) CMD (/home/oracle/backup/script/secfin)

I'm a bit stuck at this point If there is any one out there that can help I'd be eternally grateful. If there is any more info needed please let me know.

Many thanks

Jon
 
Old 01-09-2007, 07:29 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Can't see it. Wasn't there an email sent? If not you could try troubleshooting by forcing a MAILTO=some@addr.ess in the users crontab plus adding a line in the script (right below the first one) to "set -xe" which would dump debug output and exit on first error (thus forcing an email to be sent).
 
Old 01-10-2007, 03:16 AM   #3
jonnynoh
LQ Newbie
 
Registered: Jan 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks Unspawn for coming back to me. I had not even thought to check the mail log, it's always the obvious things that get missed. Anyway it doesn't seem to like line in either script as can be seen from the messages:
Message 217:
From oracle@localhost.localdomain Wed Jan 10 00:30:01 2007
Date: Wed, 10 Jan 2007 00:30:01 GMT
From: root@localhost.localdomain (Cron Daemon)
To: oracle@localhost.localdomain
Subject: Cron <oracle@localhost> /home/oracle/backup/script/secfin
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/oracle>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=oracle>
X-Cron-Env: <USER=oracle>

/home/oracle/backup/secfin/
secfinWedJan10.dmp
/home/oracle/backup/secfin/
/home/oracle/backup/script/secfin: line 10: exp: command not found

&
Message 218:
From oracle@localhost.localdomain Wed Jan 10 00:30:01 2007
Date: Wed, 10 Jan 2007 00:30:01 GMT
From: root@localhost.localdomain (Cron Daemon)
To: oracle@localhost.localdomain
Subject: Cron <oracle@localhost> /home/oracle/backup/script/secfin2
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/oracle>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=oracle>
X-Cron-Env: <USER=oracle>

/home/oracle/backup/secfin2/
secfin2WedJan10.dmp
/home/oracle/backup/secfin2/
/home/oracle/backup/script/secfin2: line 10: exp: command not found

The command in the script is:
exp system/manager@secfin FULL=Y file=/home/oracle/backup/secfin/"$dmp" log=/home/oracle/backup/secfin/"$logfile"

I did a man on exp and it's a recognised command. Could it be something to do with the fact that the oracle users default shell is KSH. But that's being sourced by the line #!/bin/sh right???

Last edited by jonnynoh; 01-10-2007 at 03:17 AM.
 
Old 01-10-2007, 04:13 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by jonnynoh

I did a man on exp and it's a recognised command. Could it be something to do with the fact that the oracle users default shell is KSH. But that's being sourced by the line #!/bin/sh right???
The man page of exp refers to the exponential function in C language. In your case exp is an ORACLE function. You have to put the full path of exp in your script, e.g.

${ORACLE_HOME}/bin/exp ...

where ${ORACLE_HOME} refers to the directory where Oracle has been installed.
 
Old 01-10-2007, 03:55 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
and there you have it...
 
Old 01-16-2007, 07:37 AM   #6
jonnynoh
LQ Newbie
 
Registered: Jan 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Hello again,
I just got word from the developer that it's still not working even though he now references the full path to exp:

[root@localhost script]# more secfin
#!/bin/sh
logfile="secfin`date +%a%b%d`.log"
dmp="secfin`date +%a%b%d`.dmp"
path=/home/oracle/backup/secfin/

echo $path
echo $dmp
echo $path

/home/oracle/product/9.2.0/bin/exp system/manager@secfin FULL=Y file=/home/oracle/backup/secfin/"$dmp" log=/home/oracle/backup/secfi
n/"$logfile"

Thanks so much for the help so far but any other ideas?

Jonny
 
Old 01-16-2007, 04:21 PM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
What about the error messages from mail log? Are they the same as before?
 
Old 05-30-2009, 11:07 AM   #8
jsmithstl
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 1
Probably too late, but....

Sorry for posting on a thread that's this old, but just in case someone else has this problem...

You're problem is that the cron does not automatically source profiles. You have to source it in your script (a good practice anyway).

Either of the two solutions below will work.

#!/bin/ksh

#
# source the profile
#
. ~/.profile

#
# If you don't want to see the output,
# you can redirect the output
#
# This will redirect STDOUT AND STDERR to /dev/null
# so you won't see it.
#
. ~/.profile > /dev/null 2>&1
 
1 members found this post helpful.
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
installation of RHEL-4 Update 3 vivek reddy Linux - Software 2 03-29-2006 02:35 AM
I need Update 5 for RHEL v3 quedog96 Linux - Enterprise 2 12-14-2005 09:53 AM
RHEL-ES-V3 update jeganraj Red Hat 2 11-20-2005 11:47 PM
RHEL 3 AS U4 Issue alexander_goron LinuxQuestions.org Member Success Stories 0 04-12-2005 09:52 PM
Cron & ksh: Solaris/RHEL 2 incompatibility marist89 Linux - Software 1 01-21-2004 03:48 PM

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

All times are GMT -5. The time now is 12:08 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