1830165 Members
2400 Online
109999 Solutions
New Discussion

rc=1

 
SOLVED
Go to solution
Sanjiv Sharma_1
Honored Contributor

rc=1

Hi,

I have a rp8400/HP-UX 11i. All the cronjobs running under oracle user is failing with the error in /var/adm/cron/log as rc=1.

I have restarted the server and prior to restart the cronjob were running w/o any error.

I have even created a test cronjob but it fails too.
$ crontab -l

05,10,15,20,25,30 * * * * date > date.log

/var/adm/cron/log

CMD: date > date.log
> oracle 26954 c Mon Dec 1 10:25:00 SST 2003
< oracle 26954 c Mon Dec 1 10:25:00 SST 2003 rc=1

The same test cronjob is working for another users like root.

What has gone wrong?

Thanks,
Everything is possible
12 REPLIES 12
Steven E. Protter
Exalted Contributor

Re: rc=1

Obvious question?

Does the user in question have execute permissions on the file /usr/bin/date

I think you would get a return code(rc) of 1 if you tried to execute it and had no permissions.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Michael Tully
Honored Contributor

Re: rc=1

cron is really stupid, try the full path of the date program:

05,10,15,20,25,30 * * * * /usr/bin/date > date.log

Has the 'oracle' user have an entry in the cron.allow file?


Anyone for a Mutiny ?
Sanjiv Sharma_1
Honored Contributor

Re: rc=1

Yes the oracle user has execute permission on the date command.
/usr/bin> ll date
-r-xr-xr-x 1 bin bin 16384 Nov 14 2000 date

Also I am able to execute the date command crom command line.

Thanks,
Everything is possible
Sanjiv Sharma_1
Honored Contributor

Re: rc=1

I have given the full path now:

05,10,15,20,25,30 * * * * /usr/bin/date > date.log

But it still fails with the same error.

'oracle' user have an entry in the cron.allow file.

Thanks,
Everything is possible
Con O'Kelly
Honored Contributor

Re: rc=1

Hi Sanjiv

Try to explicitly set the full path for date.log & write it to /tmp.
05,10,15,20,25,30 * * * * /usr/bin/date > /tmp/date.log

cron will try to write the date.log file to the users home directory. Are the permissions correct on this directory (ie the Oracle Home).

Cheers
Con
Kevin Wright
Honored Contributor

Re: rc=1

where are you writing date.log too? It is very important in cron to use absolute paths at all times in your scripts.
Bill Hassell
Honored Contributor

Re: rc=1

The rc=1 in the cron logis the return code. rc=0 is OK and rc=non-zerois a problem. Unfortunately, there isn't enough information on what the non-zero value is reporting. root generally works for most everything so when an ordinary user fails, the issue is usually permissions. But avoid changing everything to 777 permissions! Instead, look at the location for date.log. Since date.log is not a fullpath, it's location is *NOT* the user's $HOME. $PATH and most all the other env variables that are set with a login will not be set as cron does not login--it simply runs on behalf of the user. My guess is that date.log is going to be stored in / and that is one of the many directories un which ordinary users can never create files or directories. Specify a fullpath to date.log, perhaps /var/tmp.


Bill Hassell, sysadmin
Con O'Kelly
Honored Contributor

Re: rc=1

Hi (again)

Unless I'm reading it wrong the crontab man page states that cron supplies a default environment (albeit a very limited one) for every shell which *includes* the users HOME directory.

It also states that the command is invoked from the users home directory, which would imply that the if no path is given then date.log will be written to the users home directory (ie the directory where it was invoked) rather than the / fileystem.

My guess is that the permissions have gotten messed up on the Oracle Home. Possibly all your oracle cron jobs output to Oracle Home??

Cheers
Con
Bill Hassell
Honored Contributor

Re: rc=1

Con is correct. I was thinking about $PATH and mentioned $HOME without checking. Since most of my cron jobs never use $HOME, I just assume that files without a leading / are going to the 'wrong' location.


Bill Hassell, sysadmin
Sanjiv Sharma_1
Honored Contributor

Re: rc=1

Hi All,

I have changed the cron to
05,10,15,20,25,30 * * * * /usr/bin/date > /tmp/date.log

But still the same problem.

Thanks,
Everything is possible
Con O'Kelly
Honored Contributor

Re: rc=1

Hi

Seems very strange.
Check if other users apart from root can successfully execute cron jobs?

Maybe post output of the following commands:
# pwget -n oracle
$ ll -d $HOME (logged in as oracle user)
# ll /tmp/date.log
# ll /var/spool/cron/crontabs/oracle

Cheers
Con


Con O'Kelly
Honored Contributor
Solution

Re: rc=1

Hi

One other thing, check your oracle mail for messages from cron.
cron normally generates a mail for jobs that fail. The mail message often gives more detail than the cron log on the reason for the failure.

Cheers
Con