1748156 Members
3965 Online
108758 Solutions
New Discussion юеВ

Re: Cron and UTL problem

 
David_335
New Member

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 11
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
New Member

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
New Member

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