I have one script which takes data from table and spools it into a file.
When i am running manually all is fine but while trying same script thru crontab the spooled file is not getting generated.....
The mail part is working fine....only prob is the spooled file.
I only placed file on server and also did entry in crontab..!
The script is running fine if i manually run at that location but everything remaining same when it runs from crontab entry the spooled_file is not getting created.....!
Which Operating System?
Which Shell?
Which database engine?
What is in the script?
What is in the crontab line?
Which user did you use test from the command line?
Which user owns the crontab?
Any error messages in unix mail for the user?
There still may be a question about which user? When issuing the "crontab" command the default user is "root" unless you specify a different user. If we assume that this is a root cron it may be inappropriate to run an Oracle program if Oracle is using the unix username for authentication.
For example when I use root cron to run a script as user "oracle" I use something like this:
15 20 * * * su oracle -c "/home/oracle/scripts/scriptname"
Tip about cron. Write a one line script and run it once from cron to see the cron environment. Then compare with the the output from "env" in the user environment.
env >/tmp/cron_env.lst
Footnote:
I can't explain why there were not error messages in mail for the user. If this is a root cron, the errors should be in root mail.
"Tip about cron" was to write a very simple script to find out what the environment looks like in cron. It will tell you that is a skeleton environment which is nothing like the environment for an interactive user and may not even be using the same shell.
Try the simple "env" cron for practice. It will also show you that redirect to a log works. It of course only works if there is any output. Ideally in your Live script you will have already redirected any output to log files in which case there is nothing left to capture on the crontab line itself. I say ideally because all unredirected output turns up in mail for the user of the cron which is just about the least useful place!