1

I have created a script to gather stats on my oracle 12c database and given execute permission. Once i executed the scripts it works fine. But if i execute it through a cronjob it s not working as expected. Only the date of log file is updated and nothing in it as normal execution of the script. what would be the reason to fail the cron job

script and cron job as follows

sqlplus / as sysdba <<EOF

exec dbms_stats.gather_schema_stats('SIEBEL');

exit;

EOF

cronjob

19 12 * * * /export/home/oracle/amalw/stat_gather.sh > /export/home/oracle/amalw/stat_gather.log

db.env profile is at /export/home/oracle location

Amal
  • 91
  • 1
  • 8
  • 4
    Why are you using cron for this? Please read https://docs.oracle.com/cd/B28359_01/server.111/b28310/scheduse.htm#i1033533 – Ed Heal Apr 20 '18 at 07:17

1 Answers1

0

Redirect the error output to your log file with 2>&1:

 19 12 * * * /export/home/oracle/amalw/stat_gather.sh \
     > /export/home/oracle/amalw/stat_gather.log 2>&1

Or tell crond to mail you by adding to the top of the crontab:

MAILTO=you@gmail.com
Andomar
  • 232,371
  • 49
  • 380
  • 404