This discussion is archived
8 Replies Latest reply: Sep 19, 2012 9:26 AM by Ani RSS

exadata env. cron- script not working

Ani Newbie
Currently Being Moderated
HI All,

I am working on exadata environment. Application team require some reports on every Sunday. So we put the below mentioned script on cron. when we are running those command manually it is working fine but when it is running through cron all the logfile size become 0. could you give me some idea why it is showing 0 bytes..Pplease let me is there anyway where i can post attachment here.i am new to this forum.


0 7 * * 0 /tech/support/bin/weekly__metric_report.sh

=====================================================
#!/bin/sh
dcli -g /root/cell_group -l cellmonitor "cellcli -e list metrichistory CD_IO_RQ_R_LG_SEC where metricObjectName like \'CD_.*\'" > /Exadata_export/Weekly_Metric_Report/CD_IO_RQ_R_LG_SEC.log
dcli -g /root/cell_group -l cellmonitor "cellcli -e list metrichistory CD_IO_RQ_R_SM_SEC where metricObjectName like \'CD_.*\'" > /Exadata_export/Weekly_Metric_Report/CD_IO_RQ_R_SM_SEC.log
dcli -g /root/cell_group -l cellmonitor "cellcli -e list metrichistory CD_IO_RQ_W_LG_SEC where metricObjectName like \'CD_.*\'" > /Exadata_export/Weekly_Metric_Report/CD_IO_RQ_W_LG_SEC.log
dcli -g /root/cell_group -l cellmonitor "cellcli -e list metrichistory CD_IO_RQ_W_SM_SEC where metricObjectName like \'CD_.*\'" > /Exadata_export/Weekly_Metric_Report/CD_IO_RQ_W_SM_SEC.log
dcli -g /root/cell_group -l cellmonitor "cellcli -e list metrichistory FC_IO_RQ_R_SEC" > /Exadata_export/Weekly_Metric_Report/FC_IO_RQ_R_SEC.log
dcli -g /root/cell_group -l cellmonitor "cellcli -e list metrichistory FC_IO_RQ_W_SEC" > /Exadata_export/Weekly_Metric_Report/FC_IO_RQ_W_SEC.log
dcli -g /root/cell_group -l cellmonitor "cellcli -e list metrichistory FC_IO_BY_R_MISS" > /Exadata_export/Weekly_Metric_Report/FC_IO_BY_R_MISS.log
============================================================

===========================================================
ALL are showing 0 byets

-rw-r--r-- 1 root root 0 Sep 9 07:00 CD_IO_RQ_R_LG_SEC.log
-rw-r--r-- 1 root root 0 Sep 9 07:00 CD_IO_RQ_R_SM_SEC.log
-rw-r--r-- 1 root root 0 Sep 9 07:00 CD_IO_RQ_W_LG_SEC.log
-rw-r--r-- 1 root root 0 Sep 9 07:00 CD_IO_RQ_W_SM_SEC.log
-rw-r--r-- 1 root root 0 Sep 9 07:00 FC_IO_RQ_R_SEC.log
-rw-r--r-- 1 root root 0 Sep 9 07:00 FC_IO_RQ_W_SEC.log
-rw-r--r-- 1 root root 0 Sep 9 07:00 FC_IO_BY_R_MISS.log
$
  • 1. Re: exadata env. cron- script not working
    BillyVerreynne Oracle ACE
    Currently Being Moderated
    Keep in mind that cron spawns a child process WITHOUT running the +.bash_profile+ for that o/s user, when running a script for that o/s user.

    This means that if that script's contents rely on environmental variables like ORACLE_HOME and so on - these will not be set. And this will cause such commands in the script to fail. The same script will however execute fine from the command line as that interactive shell session will have a valid environment.

    Two basic choices.

    Set the environment name-values in that crontab file. See cron documentation for details.

    Check for a valid environment in that script - if not detected, source the +.bash_profile+ environment settings manually. Only then proceed in the script with the running of the commands and code in the script.
  • 2. Re: exadata env. cron- script not working
    Dude! Guru
    Currently Being Moderated
    In addition to the previous reply, cron by default also sends a report by mail. You might want to check the output.

    Perhaps you can solve your problem by including the full path to the "dcli" utility in your shell script, including any env variables necessary.

    Regarding attachments, as the Oracle forum "super admin" points out, there is and won't be attachments for non Oracle employees. Perhaps you find the following info useful: How can I attach a file to a post
  • 3. Re: exadata env. cron- script not working
    Ani Newbie
    Currently Being Moderated
    Thanks for your reply. Please tell me what i will change here. I am running this script from cron. my shell is bash.
  • 4. Re: exadata env. cron- script not working
    Ani Newbie
    Currently Being Moderated
    Hi Dude,

    so you mean this will work right?


    /usr/local/bin/dcli -g /root/cell_group -l cellmonitor "cellcli -e list metrichistory CD_IO_RQ_R_LG_SEC where metricObjectName like \'CD_.*\'" > /Exadata_export/Weekly_Metric_Report/CD_IO_RQ_R_LG_SEC.log

    Regards,
    Ani
  • 5. Re: exadata env. cron- script not working
    Dude! Guru
    Currently Being Moderated
    You can probably try it manually.

    Simply login as the user for which the cron task is defined then, for example:

    <pre>
    ssh -t localhost "/bin/sh --noprofile"
    </pre>

    I have not tested this but you can try and see if it works.
  • 6. Re: exadata env. cron- script not working
    Ani Newbie
    Currently Being Moderated
    i am running it as root ...so i need to specify the full dcli path only right
  • 7. Re: exadata env. cron- script not working
    Dude! Guru
    Currently Being Moderated
    Cron will only search for programs in /usr/bin and /bin. So in order for cron to find a program that is not in /usr/bin or /bin, you either need to specify a $PATH environment variable in your shell script, or simply use the absolute path to the program.

    I don't know where you have the dlci program stored, but you can try to login as root and type:

    <pre>
    which dcli
    or
    /usr/local/bin/dcli
    or
    ls -l /usr/local/bin/dcli
    </pre>

    and see what happens. Then specify the full path in your script, e.g. /usr/local/bin/dcli

    I recommend to add "2>&1" to your command to include possible errors in your logfile, for instance:

    <pre>
    /wrong/path/ls -l > out.log 2>&1

    cat out.log
    -bash: /wrong/path/ls: No such file or directory
    </pre>

    Edited by: Dude on Sep 19, 2012 8:38 AM
  • 8. Re: exadata env. cron- script not working
    Ani Newbie
    Currently Being Moderated
    Hi Dude,

    Thank you so much for your quick response . I will try this & let you know.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points