Operating System - HP-UX
1827305 Members
2402 Online
109961 Solutions
New Discussion

cronjob not working by oracle user

 
SOLVED
Go to solution
vjta
Regular Advisor

cronjob not working by oracle user

Hi All!
My customer is having HP-ux 11.31 with oracle installed & user is xoracle.
my crontab entry for xoracle user is
$ crontab -l
0,10,20,30,40,50 * * * * sh /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH
0,10,20,30,40,50 * * * * date>/tmp/vjta1.txt


but its not working i have tried with su -xoracle -c <script> with root user crontab still its not working.

Pls help

Thanks
vjta
Vijeta Bhedi
16 REPLIES 16
Rasheed Tamton
Honored Contributor

Re: cronjob not working by oracle user

Hi Vjta,

Check your /usr/lib/cron/cron.allow (linked to /var/adm/cron/cron.allow) file. You can execute crontab only if your name appears in that file. Also look in /var/adm/cron/log file for errors.

If there are no entried in the above file, add the user names you want the cron to execute one by one as below:

root
oracle

Regards,
Rasheed Tamton.
vjta
Regular Advisor

Re: cronjob not working by oracle user

Hi Rasheed !
Thanks for ur Reply I already added user entry in cron.allow * in logs its not showing anything.
Pls see:
# pwd
/var/adm/cron

# cat cron.allow
root
adm
uucp
xoracle

Thanks
vjta
Vijeta Bhedi
Rasheed Tamton
Honored Contributor

Re: cronjob not working by oracle user

>,10,20,30,40,50 * * * * sh /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH
0,10,20,30,40,50 * * * * date>/tmp/vjta1.txt

In that case, just give the full path for the commands you use in the cron, i.e., instead of sh give the full path of sh (/usr/bin/sh) and do it for the date also. You have to always give the full path of the commands when you use it in the cron.

Regards.
Rasheed Tamton
Honored Contributor

Re: cronjob not working by oracle user

Why do not you do the shell script executable instead of giving sh in the cron.

Regards.
Dennis Handly
Acclaimed Contributor

Re: cronjob not working by oracle user

>I have tried with su -xoracle -c <script>

I assume the missing space between the "-" and xoracle is just a typo?
vjta
Regular Advisor

Re: cronjob not working by oracle user

Hi !
Pls seee my crontab entry:
# crontab -l
0,10,20,30,40,50 * * * * su -xoracle -c date>/tmp/vjta1.txt
0,10,20,30,40,50 * * * * su - xoracle -c usr/bin/sh /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH


can u pls tell me how to deal with executable script in crontab

regards
Vjta
Vijeta Bhedi
vjta
Regular Advisor

Re: cronjob not working by oracle user

Hi !
Pls seee my crontab entry:
# crontab -l
0,10,20,30,40,50 * * * * su - xoracle -c date>/tmp/vjta1.txt
0,10,20,30,40,50 * * * * su - xoracle -c usr/bin/sh /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH


can u pls tell me how to deal with executable script in crontab

regards
Vjta
Vijeta Bhedi
Rasheed Tamton
Honored Contributor

Re: cronjob not working by oracle user

>su - xoracle -c date>/tmp/vjta1.txt
replace date with the full path /usr/bin/date


which date
/usr/bin/date

>usr/bin/sh /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH
(a slash is missing)

/usr/bin/sh

making executable:
ll /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH
check the permission of the file
chmod +x /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH


rgds.
vjta
Regular Advisor

Re: cronjob not working by oracle user

Hi!

for 1st entry i.e.

0,10,20,30,40,50 * * * * date>/tmp/vjta1.txt

its working & see the o/p of txt file

# cat /tmp/vjta1.txt
(c)Copyright 1983-2006 Hewlett-Packard Development Company, L.P.
(c)Copyright 1979, 1980, 1983, 1985-1993 The Regents of the Univ. of California
(c)Copyright 1980, 1984, 1986 Novell, Inc.
(c)Copyright 1986-2000 Sun Microsystems, Inc.
(c)Copyright 1985, 1986, 1988 Massachusetts Institute of Technology
(c)Copyright 1989-1993 The Open Software Foundation, Inc.
(c)Copyright 1990 Motorola, Inc.
(c)Copyright 1990, 1991, 1992 Cornell University
(c)Copyright 1989-1991 The University of Maryland
(c)Copyright 1988 Carnegie Mellon University
(c)Copyright 1991-2006 Mentat Inc.
(c)Copyright 1996 Morning Star Technologies, Inc.
(c)Copyright 1996 Progressive Systems, Inc.

Confidential computer software. Valid license from HP required for
possession, use or copying. Consistent with FAR 12.211 and 12.212,
Commercial Computer Software, Computer Software Documentation, and
Technical Data for Commercial Items are licensed to the U.S. Government
under vendor's standard commercial license.

Tue Aug 5 14:20:00 IST 2008
logout


here date is showing in 2ndlast line
whereas in log its shwing:
root 12814 c Tue Aug 5 14:20:00 IST 2008
< root 12812 c Tue Aug 5 14:20:00 IST 2008
< root 12814 c Tue Aug 5 14:20:00 IST 2008 rc=127
< root 12813 c Tue Aug 5 14:20:00 IST 2008 rc=127

ended with rc=127

regards
Vjta
Vijeta Bhedi
Rasheed Tamton
Honored Contributor
Solution

Re: cronjob not working by oracle user

Hi,

rc=127 means that you are using the non-shell commands. Either the path for the commands are missing in the script. Check whether you have put the full path for the commands in the script.

Use -x in the shell (sh -x) or set -x to get the verbose output of the commands and redirect the output to a file as you did with the date command.

/usr/bin/sh -x scriptname

rgds.
F Verschuren
Esteemed Contributor

Re: cronjob not working by oracle user

please make sure if you are running a script from cron that the first line of the script is:
#!/bin/ksh
(or a other shell)
that normaly will fix the error.
Dennis Handly
Acclaimed Contributor

Re: cronjob not working by oracle user

>su - xoracle -c usr/bin/sh /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH

As mentioned by Rasheed, why use sh to execute your scripts?

The -c option needs to have its whole command quoted:
"/usr/bin/sh /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH"
chindi
Respected Contributor

Re: cronjob not working by oracle user

hi vita,

Can u please share d script with us...
i mean cat /usr/bin/sh /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH..

i suspect the ORACLE_HOME,ORACLE_SID not set in ur script...

please try it....
vjta
Regular Advisor

Re: cronjob not working by oracle user

hi ,

sorry for the delay.

this script is running manually only problem thru cron.
Vijeta Bhedi
OldSchool
Honored Contributor

Re: cronjob not working by oracle user

"0,10,20,30,40,50 * * * * su - xoracle -c usr/bin/sh /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH"

either:

0,10,20,30,40,50 * * * * su - xoracle -c /usr/bin/sh /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH

or in the script XOSUPLOADBATCH, make sure the first line is
#!/usr/bin/sh

then make the crontab entry:
0,10,20,30,40,50 * * * * su - xoracle -c /XOSoracle/XOSUPLOADBATCH/XOSUPLOADBATCH

If you still have issues, bear in mind cron supplies a very limited environment. You will probably need to fix the PATH or add full pathes to all commands for instance.
vjta
Regular Advisor

Re: cronjob not working by oracle user

Thanks To ALL!!
Vijeta Bhedi