Operating System - HP-UX
1753805 Members
7533 Online
108805 Solutions
New Discussion юеВ

Scripts is not working in cron

 
SOLVED
Go to solution
DhamoThulasi
New Member

Scripts is not working in cron

Hi experts ,

I am running the bellow scripts in cron job its not working but when i ran in normal its working fine , can you pls help me to get resolve it.

$ more chkorainst
#!/bin/ksh
# Check for PGGPDM_D1.world Oracle instance
#echo "Timestamp: `date` STATUS: `tnsping PGGPDM_D1.world | tail -1`" >> /opt/ma
trix/admin_scripts/chkorainst.output 2>&1
echo "Timestamp: `date` STATUS: " >> /opt/matrix/admin_scripts/chkorainst.output
2>&1
exit
$ ./chkorainst
$ ls
chkorainst filesystemmonitor rbtmtr rbtwas rbtwas_old
chkorainst.output finalwarn rbtmtr.txt rbtwas.txt warn
$ more chkorainst.output
Timestamp: Thu Jul 5 10:05:35 EDT 2007 STATUS:
$ ./chkorainst
$ more chkorainst.output
Timestamp: Thu Jul 5 10:05:35 EDT 2007 STATUS:
Timestamp: Thu Jul 5 10:09:48 EDT 2007 STATUS:
4 REPLIES 4
Geoff Wild
Honored Contributor
Solution

Re: Scripts is not working in cron

Specify full path to any programs....like /usr/bin/echo, tnsping, etc...

Most cases this is attributed to environment variables - like PATH....

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Basheer_2
Trusted Contributor

Re: Scripts is not working in cron

Hi Thulasi

The most common cause for this not being able to run from cron is bcoz of the PATH.

edit the script and add the profiile, if user oracle is running this script, then

. /home/oracle/.profile

(absolute path of the user who is running the script )

this will provide all the needed PATH and ENV variables.

Dennis Handly
Acclaimed Contributor

Re: Scripts is not working in cron

>Geoff: Specify full path to any programs like /usr/bin/echo

Since echo is a shell builtin, that's not needed for it.
You are correct about the other causes.
Hein van den Heuvel
Honored Contributor

Re: Scripts is not working in cron


As Geoff indicates cron jobs start out with limited environment set up. Your first step shoudl proabbly be to run a .profile or such to set up $PATH, $ORACLE_SID and so on.

There are many, many prior questions and answer about this in this very forum
To find those. Google: +cron +oracle +site:itrc.hp.com
For example:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=31119

If those answers fail to provide you with the help you need, then please be sure to re-reply with an exact description of why you think your job failed. Any particular error message? Can you cron a write with 'echo hello world'? Can you con a script to show the environement setup?


Hope this helps some,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting