Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

Cron and UTL problem

David_335
Occasional Visitor

Cron and UTL problem

Hello, thanks and sorry for my english:

I have a very huge problem I try to explain correctly:

I have a shell that calls a pl-sql program, after a pro-cobol program and after another pl-sql program. This shell works correctly and do every thing that I want. The problem is when I put into the cron, the first pl-sql programs works ok, the procobol too and the last pl-sql exists for the exception SYS.UTL_FILE.INVALID_OPERATION. This pl-sql opens one file for reading and four for writing, and when is trying to open the third file exists for the mentioned exception.

I like to be clear about this shell works correctly when I execute in a normal unix sesion and its when I put in the cron when fails.

Do you know if there is any tipe of limit obout files when a pl-sql program runs in the cron, its the only idea that I have.

Thanks

David
11 REPLIES
John Poff
Honored Contributor

Re: Cron and UTL problem

Hi David,

When you run scripts from cron, you don't have the full user profile executed so you don't have all your normal environmental variables set. Probably the last pl-sql program needs something in one of your variables that gets set in the .profile, such as the PATH, or maybe another variable that sets a path for the third file to be opened?

JP
Pete Randall
Outstanding Contributor

Re: Cron and UTL problem

David,

I have no idea if this is related or not, but the usual limitation with cron that trips people up is cron's minimal environment setup. There's no PATH to speak of, probably very few of you DB environment variables, etc. The thing to do with cron is always use full path names for commands and make sure that whatever environment variables you need are being set in the script. I'm wondering if maybe you're missing one of your DB env vars
when the second sql program runs.

Pete

Pete
john korterman
Honored Contributor

Re: Cron and UTL problem

Hi David,
the last pl-sql is perhaps depending on an environment variable not set when executed from cron. Do you execute it as the same user from cron? Try comparing the two environments by inserting these two lines in your script:
env | sort >/tmp/cron.env
exit
and execute it from cron.
Then, as the user where it works:
# env | sort >/tmp/user.env
And look for the difference:
# diff /tmp/user.env /tmp/cron.env

regards,
John K.

it would be nice if you always got a second chance
David_335
Occasional Visitor

Re: Cron and UTL problem

Hello, everybody says me that problably i have lost the environment but I make an "env" in a normal session and one in the cron and the results are the same and its a little extrange that two of the files were opened but the third exits for the exception, I'm trying to flush the buffer of the files but I think it isn't the matter, I'm becoming mad, I need a solution, ahhhhhh
Yogeeraj_1
Honored Contributor

Re: Cron and UTL problem

hi,

difficult to understand your problem. Can you please post your code from the problem script and cron?

regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Bill Hassell
Honored Contributor

Re: Cron and UTL problem

Having the same environment in cron as you do in a normal login is not normal at all. If you look at the man page for cron you'll see a VERY small PATH and minimal environment variables setup. Perhaps your job uses su - ? If so, then there will be a batch job login, but this is not quite the same as an interactive login because there is no controlling terminal and some of the profile code will fail.

All failures in cron (versus an interactive login) are due to missing components in the working environment and lack of a controlling terminal. Add to the test for env a test for ulimit (ulimit -a). This assumes you are using the standard POSIX shell for your scripting. You'll have a LOT of problems trying to make csh (or other non-standard shell) work in a cron environment. Note that *ALL* cron shell scripts must have the courtesy loader directive (ie, #!/usr/bin/sh) as line numer 1. Actually, all shell scripts should have this line but cron is crucially dependent on being told which shell to use.


Bill Hassell, sysadmin
David_335
Occasional Visitor

Re: Cron and UTL problem

I'm thinking that we are in the correct way, you are rigth, this shell is execute in the cron with "su" and I don't put "#!/usr/bin/sh" in any of my shells, I'm very worried because I said thath all of my env var are the same but one is diferent and problably affect, the shell in a normal sesion is "SHELL=/usr/bin/ksh" and in the cron is "SHELL=/sbin/sh", sorry.

I haven't acces to the cron and i can't see how they put my shell in the cron, all are problems for every thing.

The ulimit -a doesn't work but ulimit alone yes, it's 4194303 (in a normal session) and in the cron the ulimit -a works and its output is time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 1048576
stack(kbytes) 131072
memory(kbytes) unlimited
coredump(blocks) 4194303
nofiles(descriptors) 2048

A lot of thanks
john korterman
Honored Contributor

Re: Cron and UTL problem

Hi again,
as already stated, you should insert
#!/usr/bin/sh
at the beginning of all your scripts.
I think that the root shell, /sbin/sh, does not support the functionality of some of your variables, e.g. NLS_LANG.

regards,
John K.
it would be nice if you always got a second chance
Bill Hassell
Honored Contributor

Re: Cron and UTL problem

The reason that ulimit -a does not work in your shell is that your shell is ksh and ksh does not allow for any options. That's one of the many reasons to use the POSIX shell rather than ksh. Your ksh script should run without a problem under /usr/bin/sh. Unfortunately, your application is making the problem very difficult to find because of the useless error message. It should be returning the standard Unix errno value as well as the name of the file.


Bill Hassell, sysadmin
David_335
Occasional Visitor

Re: Cron and UTL problem

Hello to everybody, I'm happy because I arranged my problem this week.
During two or three weeks I didn't work in my normal work, I was doing others things
but the last week I try to arrange y problem and I did it.
The problem it's so stupid like near all in computers, you have to remember that my
shell call a pl-sql after a pro-cobol and after another pl-sql, in the shell the ouput from
the pro-cobol generates a file ( pro-cobol > filename ), this file is opened by the second
pl-sql for writing and it's here where it fails, I change the name of the output in the pro-cobol
and all works ok, it's strange because it's unnecessary in a normal session
but in the cron it's necessary.

I hope it helps to any person.

Tim Sanko
Trusted Contributor

Re: Cron and UTL problem

First put in the cron patch. If you are running this out of cron, are you running it as root?

I saw exps have similar problems. The cron patch fixed it on an 11.0 system...

TJS