Error with dbms_scheduler and shell script execution

Hi,guys.
I have an issue with a dbms_scheduler and a shell script execution. So, the shell script as it self works fine, when i'm executing ./test.sh all process is running, but when i'm executing the script from dbms_scheduler it just simply doesn't work. Actually it works, but some of executable information in sh doesn't work, seems it just jump over of the part of the script. Sendmail part is running, maybe there is problem with rman script as it self?
DB version: 10g
And my scripts:
Shell scripts (permisons 755):
#!/bin/ksh
export PATH=/home/oracle/product/asm_home/bin:/home/oracle/product/db_home/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/oracle/bin:/usr/bin/X11:/sbin:.
export ORACLE_BASE=/home/oracle/product
export ORACLE_SID=zabbix
export ORACLE_HOME=/home/oracle/product/db_home
${ORACLE_HOME}/bin/rman<<EOF
connect target /
run {backup recovery area delete all input;}
EOF
{       echo "From:[email protected]"
        echo "To: [email protected]"
        echo "Subject: Recovery area"
        echo 'Content-Type: text/html'
        echo
        echo '<html><body><table border="1" cellspacing="1">'
        echo '<tr><td><b>Process</b></td><td><b>Statuss</b></td></tr>'
        echo "<tr><td>RMAN</td><td><b>Works</b></td></tr>"
        echo "</table></body></html>"
} | sendmail -tIn the first part i'm exporting all of the important stuff for oracle, then I call RMAN with specific atributes. And then there is just simply sendmail functionality inside script to represent if script works (for now).
And below pl/sql script:
begin
  DBMS_SCHEDULER.CREATE_JOB
  job_name => 'FLASH_RECOVERY',
  job_type => 'EXECUTABLE',
  job_action => '/home/oracle/backup/test.sh',
  start_date => sysdate,
  job_class => 'DEFAULT_JOB_CLASS',
  enabled => TRUE,
  auto_drop => FALSE,
  comments => 'FLASH RECOVERY USAGE AREA backup and delete'
  END;
  /And this job execution:
       begin
           DBMS_SCHEDULER.run_job (job_name =>'FLASH_RECOVERY',use_current_session => TRUE);
       end;What can be wrong? For me, I think it's something with permisions.
I hope you got my idea and could help me.
Tom
Edited by: safazaurs on 2013.18.2 22:16

There is no error, i just receive all the time e-mail, seems it jumps over rman. I tried almost everything and still couldn't get result as i want. And, if i'm running script from command line - it works. Rman calls, and starts to recover archivelogs.

Similar Messages

  • DBMS_SCHEDULER and Shell Script on 10.2.0.1

    Hi All
    My env, Oracle 10.2.0.1 and OS is Solaris.
    My script can run on OS that is work without error that contain create file, delete file, call sqlplus, function to get value from database and return to OS variables.
    In shell script some code as below
    get_val () {
    sqlplus -s /nolog <<EOF
    conn test/test
    set heading off
    set feedback off
    set pages 0
    SELECT SUBSTR (SYS_CONNECT_BY_PATH (Z, ' '), 2) z
          FROM (SELECT NAMEDQUERY , ROW_NUMBER () OVER (ORDER BY Z) rn,
                       COUNT (*) OVER () cnt
                  FROM X
                  WHERE Z LIKE '%FULL')
         WHERE rn = cnt
    START WITH rn = 1
    CONNECT BY rn = PRIOR rn + 1;
    EOF
    vx=$(get_val)
    if [ ${#vx} -gt 0 ]; then
    for xfile in $vx
    do
    rm -f $CURRDIR/$xfile.txt 2> /dev/null
    done
    fi
    When run by dbms_scheduler that show below error
    ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
    STANDARD_ERROR="/home/oracle/script/test.sh: syntax error at line 26: `vx=$' unexpected
    How to resolve above error?  (owner of $CURRDIR/$xfile.txt is oracle user)
    One more question, How to force dbms_scheduler that using user oracle (OS) to run shell script?, as I know, default user is nobody and Oracle version 10.2.0.2 later that have external.job.ora to set it but 10.2.0.1 doesn't have it.
    Thank you in advance,
    Hiko

    I changed scheduler by set argument as below
    dbms_scheduler.create_job (job_name=>'TEST',job_type=>'EXECUTABLE',job_action=>'/usr/bin/bash',number_of_arguments=>1);
    dbms_scheduler.set_job_argument_value('TEST',1,argument_value,'/home/oracle/test.sh');
    That is work. below is conclusion to did
    1. Change permission of $ORACLE_HOME/bin/extjob to 4750 (-rwsr-x---)
    2. Change owner of $ORACLE_HOME/bin/extjob to oracle:dba
    3. Use '/usr/bin/bash' instead of '/usr/bin/sh'
    But I found error about download file process that I'm using wget to download source file in shell script and run by dbms_scheduler as above.
    My problem, first file can download normally and process until finish but second file was hang.
    Do you have any idea or solution to prove and resolve it?
    Thank you,
    Hiko

  • Help 'Exiting' after Automator Shell Script Execution

    Hello,
    I've recently installed and got running GCalDaemon (http://gcaldaemon.sourceforge.net/) which allows me to Synch Rainlendar <-> Google Calendar through iCal (You can also synch iCal <-> Google Calendar). I needed to start up a shell script/applescript after each startup/login in order for GCalDaemon to start the synching process each time and continue to do so at the timed intervals. I would do so by the following terminal code:
    cd /usr/local/sbin/GCALDaemon/bin
    ./standalone-start.sh
    I then tried automating this process and came across shell script execution through Automator. I did so and created a .app with the above mentioned code. This works and it starts up the necessary .sh file I need and the snyching works under StartUp. My concern is however, how do I exit terminal once the code has executed the necessary file? All I have in my .app is the above mentioned code for now. I just need it to exit terminal because on startup or after starting the program, I get this issue (See Attachment)
    This continues to run, so my guess is that I need to add code to exit terminal and allow the .app to close itself properly after doing so.
    Please guide me in the right direction.
    Picture Belows shows what happens when I run the Automator App. It continues to run until I quit out of the app manually (TheGCal programs works fine though). I feel I need to have app quit Terminal or fully end the process and quit out on it's own.
    Thanks
    <table style="width:auto;"><tr><td></td></tr><tr><td style="font-family:arial,sans-serif; font-size:11px; text-align:right">From GCalDaemon</td></tr></table>

    i redirected the command output to /dev/null which is unix equivalent of a black hole and I also redirected error output to standard output in case the script produces any errors.
    also & at the end tells it to continue without waiting for the script to finish.
    Message was edited by: V.K.

  • SQL LOADER and SHELL SCRIPT ISSUE

    Hello Guys,
    I know this not the right forum but i am not sure where i should post this.
    Pelase help
    I am running a shell script which is giving me error
    Username:SQL*Loader-128: unable to begin a session
    ORA-01017: invalid username/password; logon denied
    SQL*Loader: Release 10.2.0.4.0 - Production on Thu Nov 19 13:02:04 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    SQL*Plus: Release 10.2.0.4.0 - Production on Thu Nov 19 13:02:06 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Enter user-name:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    0 rows updated.
    Commit complete.
    SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition
    SQL> SQL> Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options Thu Nov 19 13:02:06 EST 2009In shell script i have used the same username and passwd which i am using from command line
    the shell script is calling sql loader to load file
    and for that also the username and passwd is same.
    i am able to run sqlldr command from command line dont knw why here its giving error
    here is my shell script
    set -a
    . $HOME/.edw.env
    . $admlib/checklib.sh
    LOGDIR=$admsrc/sigma6/ppadala/copg
    LOGFILE=${LOGDIR}/log/test`date '+%m%d'`.xtr
    DB_USER=copg
    DB_PWD=copg
    set +a
    cd $LOGDIR
    if test ! -f $admsrc/sigma6/ppadala/copg/DM_Daily_EFolderCloseCancel_Report_11192009.txt
    then
       echo "Error: DM_Daily_EFolderCloseCancel_Report_11192009.txt does not exist and/or is not a regular file." >> ${LOGFILE}
       exit 1
    fi
    echo 'End of Checking for the existence of the file - Successful'>> ${LOGFILE}
    sqlldr control=$admsrc/sigma6/ppadala/copg/Close_Cancle.ctl log=$admsrc/sigma6/ppadala/copg/Close_cancle.log
    userid=${DB_USER}/${DB_PWD} silent=\(HEADER,FEEDBACK,DISCARDS\)>> ${LOGFILE} 2>&1
    case $? in 0) :;;1|3) echo "Error: SQL Loader" >> ${LOGFILE}
         exit 1;;
    esac
    sqlplus << EOD
    ${DB_USER}/${DB_PWD}
    @Close_Cancle.sql
    EOD
    if [ $? -ne 0 ]
    then
        echo "Error: SQL Plus for script Processing" >> ${LOGFILE}
        echo "Resi Unit Scheduling Report Refresh failed" >> ${LOGFILE}
    fi
    ) > ${LOGFILE} 2>&1
    echo `date` >> ${LOGFILE}
    if [ -f ${LOGFILE} ]
    then
    mail -s "Resi Unit Scheduling" "[email protected]" < ${LOGFILE}
    sleep 3
    `ck_error ${LOGFILE}`
    fiplease help guys
    thanks

    Thanks for the reply
    In Close_cancle.log also its the same msg which i posted.
    logon denied..............
    and this is the log file contents when i do set - X on
    + cd /u2144009/src/sigma6/ppadala/copg
    + test ! -f
    + /u2144009/src/sigma6/ppadala/copg/DM_Daily_EFolderCloseCancel_Report_1
    + 1192009.txt echo End of Checking for the existence of the file -
    + Successful
    + 1>> /u2144009/src/sigma6/ppadala/copg/log/test1119.xtr
    + sqlldr control=/u2144009/src/sigma6/ppadala/copg/Close_Cancle.ctl
    + log=/u2144009/src/sigma6/ppadala/copg/Close_cancle.log
    Username:SQL*Loader-128: unable to begin a session
    ORA-01017: invalid username/password; logon denied
    SQL*Loader: Release 10.2.0.4.0 - Production on Thu Nov 19 17:32:17 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    + userid=copg/copg silent=(HEADER,FEEDBACK,DISCARDS)
    + 1>> /u2144009/src/sigma6/ppadala/copg/log/test1119.xtr 2>& 1
    + :
    + sqlplus
    + 0<<
    copg/copg
    @Close_Cancle.sql
    SQL*Plus: Release 10.2.0.4.0 - Production on Thu Nov 19 17:32:58 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Enter user-name:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    0 rows updated.
    Commit complete.
    SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition
    SQL> SQL> Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    + [ 0 -ne 0 ]
    Thu Nov 19 17:32:59 EST 2009Edited by: user10647455 on Nov 19, 2009 2:35 PM

  • Rman windows and  Shell Script

    hi,
    How to take the backup by windows script and shell script.please any one tell that.
    thanks
    with regards

    Dear user!
    How to take the backup by script is a very imprecisely kind of question. So the only thing I can give you is a very imprecise answer.
    For linux shellscript you may use:
    vim my_backup_script.sh
    #!/bin/bash
    BACKUP DATABASE;Save and run this script in the following way:
    rman target / catalog catuser/password@CATDB CMDFILE my_backup_script.shYou may customize this script to fit your needs. On Windows you may write a batchscript like that:
    notepad my_backup_script.bat
    BACKUP DATABASE;Save and run this script like that:
    rman target / catalog catuser/password@CATDB CMDFILE my_backup_script.batMaybe if you could state your needs a little bit more precisely I could give you a more helpful answer.
    Yours sincerely
    Florian W.

  • Xgettext for perl and shell scripts on Solaris 9

    Hi......I have to internationalized perl and shell scripts on Linux and Solaris 9.
    I have used gettext on linux to internationalized both perl and shell scripts but on solaris i m not able to
    achieve the same.
    If we see help of xgettect on Linux, it shows input file options for Perl, Shell, C, C++ etc but help for
    xgettext on Solaris shows input file option for C only.
    Can you please provide me some way of using xgettext for perl and shell scripts on Solaris 9 or
    is there any other way of internationalizing perl and shell scripts on Solaris 9.
    Many Thanks,
    Lokesh

    Signature link blocked.
    db
    Contentprise wrote:
    Hi......I have to internationalized perl and shell scripts on Linux and Solaris 9.
    I have used gettext on linux to internationalized both perl and shell scripts but on solaris i m not able to
    achieve the same.
    If we see help of xgettect on Linux, it shows input file options for Perl, Shell, C, C++ etc but help for
    xgettext on Solaris shows input file option for C only.
    Can you please provide me some way of using xgettext for perl and shell scripts on Solaris 9 or
    is there any other way of internationalizing perl and shell scripts on Solaris 9.
    Many Thanks

  • Aborting index build. Too many errors with finding and copying files ...

    Hi dears,
    I'm using UCM 11g.
    I'm trying to start the automatic update cycle. When i start it, it gives me an error message just like :
    Indexing aborted at :<time>. Aborting index build. Too many errors with finding and copying files to the appropriate place.+
    Can anybody help me about this problem?
    Helps will be appreciated.
    Erdo
    Edited by: erdo on 28.Mar.2013 11:11

    Read this: error in Collection Rebuild Cycle
    and maybe also UCM Indexer - Collection Rebuild Cycle errorring out

  • Error in calling SQL plus program with parameter from Shell script

    This is my Shell script. I am trying to call in the SQL plus program with the parameter and the shell script is registered as a concurrent program.
    PARAMETERS=`echo $1 |tr -d '\"'`
    DB_USER_ID=`echo $PARAMETERS|cut -d" " -f3|cut -d"=" -f2`
    CONN_STRING=$DB_USER_ID
    REQ_DATE=`echo $PARAMETERS|cut -d" " -f9|cut -d"=" -f2`
    timestamp=`date +%m-%d-%y-%H:%M:%S-%Z`
    timestam=`date +%y-%m-%d`
    sqlplus -s $CONN_STRING @ar_statement.sql $REQ_DATE
    chmod 755 statement.sh
    . statement.sh
    My Sql plus program is like this.
    set pagesize 0
    set heading off
    set feedback off
    spool $GEC_TOP/log/ge_ar_statement.sh
    select output_file_name
    from fnd_concurrent_requests
    where trunc(actual_completion_date) = '&2';
    spool off;
    exit;
    When i run the concurrent program, i am getting the following error:
    ar_statement: line 14: REQ_DATE: command not found
    Enter value for 2:
    User requested Interrupt or EOF detected.
    ar_statement.sh: line 1: Enter: command not found
    ar_statement.sh: line 2: User: command not found
    ar_statement
    Program exited with status 127
    I am not strong at Unix Porgamming and i would request someone who can
    help me out as soon as possible.
    I need this solution quickly and thank everyone in advance.
    Thanks.

    Can you put your coding between code statements, like shown in the FAQ. It will be easier to read.
    Looking at your script, my first guess is that crontab will not find your sqlplus since your script does not have $HOME/bin in the $PATH. From what I understand, running .profile in your script will not work either because variables are exported to sub-shells, not to the shell above. You can call your script with a dot like . ./script which means that the script will run like it was typed at the command prompt. But it will be less confusing to define appropriate variables in the script. eg.
    ORACLE_SID=my_instance_name
    ORACLE_HOME=/my_path_to_oracle_home_directory
    LD_LIBRARY_PATH=$ORACLE_HOME/lib
    PATH=$ORACLE_HOME/bin:$PATH
    I remember some slightly different way of coding to handle the sqlplus return codes.
    For instance:
    sqlplus -s /nolog > /dev/null <<-EOF
    connect system/manager
    @ssm.sql
    whenever oserror exit failure
    whenever sqlerror exit failure
    EOF
    sql_err=$?
    if [ $sql_err -ne 0 ]; then
       echo "FAILURE"
    else
       echo "SUCCESS"
    fiThe - in -EOF supresses tab's
    Using connect will prevent ps from showing your login credentials
    In some versions of bash the ending EOF needs to be at the beginning of the line to work.
    Edited by: waldorfm on Jul 14, 2010 7:05 PM
    complaining about putting code between code delimiters and forgot myself ;-)
    Edited by: waldorfm on Jul 14, 2010 7:08 PM
    Btw, if you "source" a script running it like . .script, than an exit in that script will log you out.

  • UDM and shell scripts and working with the ENVIRONMENT variable options

    In Userdefined metrics you have the ability to pass envronment variables.
    I was going to send
    DIR=/db/db05/oradata/ORCL/hot
    How to handle whats passed to the shell script?
    It passes $1 as {DIR=/db/db05/oradata/ORCL/hot}
    yes with the brackets. Here I figured it would simply set the DIR environment variable.
    Any cool tricks to work with this mess?
    Is it meant for perl scripts instead?
    Daryl.

    Ilmari Aalto wrote:
    Hi Darth,
    Thanks for your hint! Nevertheless I think it's something more profound, since there's no error etc. For example, should I have the path wrong I assume that OWB would return me some kind of an error when it doesn't find the .sh-file? Isn't there any log-file to see whether the command was executed? It seems like the execution of the User Defined element would be skipped altogether.
    Cheers,
    IlmariNo, if you don't give an absolute path OWB will not return any error, it just wont do anything at all...

  • Applescript with Mail attachments and shell scripts (pdftk)

    I'm trying to create a script that I can call using mail rules that will:
    1. save an attached PDF file to a folder (folder name is 'PDFs_from_Mail:')
    2. save each page of the PDF as a separate file
    3. delete the old file
    so far, i used the script below called from mail to save the attachments to the
    -- script called from mail
    using terms from application"Mail"
      onperform mail action with messages theMessages
        tell application"Finder" to set ptd to (path to desktopfolder) as string
        tell application"Finder" to set pathToAttachments to(path to desktop folder as string) &"PDFs_from_Mail:"
        tell application"Mail"
           repeatwith theMessage in theMessages
                if theMessage's mailattachments is not {} then
                      repeatwith theAttachment in theMessage's mailattachments
                            settheFileName to pathToAttachments & theAttachment's name
                            try
                                     save theAttachment in theFileName
                              onerror errnum
                            endtry
                      endrepeat
                end if
             endrepeat
          end tell
      endperform mail action with messages
    end usingterms from
    tell application"Mail"
        setmyMessages to selection
        tellme to perform mail action with messages myMessages
    end tell
    -- end of script called from mail
    after the file is in the folder, i'd like to automatically call a script that splits it in to pages and saves each file.  I found pdftk can do what I need.  I got the following working, which uses a folder action script to process the file:
    -- burst script
    on addingfolder items to this_folder after receiving added_items
       tellapplication "Finder"
           set fold_name tothe name of this_folder
               try
                   repeatwith i from 1 to number ofitems in added_items
                          set theFile toitem i of added_items
                          set oldDelimiters toAppleScript's text item delimiters
                          set AppleScript's textitem delimiters to {":"}
                          set theFolder to(((text items 1 thru ((count everytext item of (theFile asstring)) -1)) of (theFile asstring))) as string
                          set AppleScript's textitem delimiters to oldDelimiters
                                --get the file name
                                   set theFileName to the name of theFile
                                                     do shell script"/usr/local/bin/pdftk " & (POSIX path oftheFile) & " burst output " & (POSIXpath of theFolder) & "/" & theFileName &"_%03d.pdf"
                                                      delete theFile
                                                    endrepeat
                                        end try
                         endtell
    end adding folder items to
    -- end burst script
    the shell script that is called is in the format:
    pdftk myfile.pdf burst
    the output parameter basically adds the page number to the end of the original filename for each file that is created
    my idea was to attach the folder action script to the 'PDFs_from_Mail' folder, and when the first script is called, the file would be saved to that folder and trigger the folder action script burst the file.  it works for individual messages, but when I try using it with the hundreds of messages that I have, all kinds of crazy things happen... the filenames are all wrong and it seems like it goes on infinitely.
    My familiarity with applescript is somewhat limited (as you may have guessed) and I'm wondering if there is a better approach.  perhaps if I incorporate the shell script into the script called from mail it may streamline everything.
    my problem is that I am not sure what code I need to keep in each script.
    can anyone take a quick look at this and give me some advice?
    my goal is to have these individual pages in a folder so that I can use quick view to page through them.  if the pdf is more than one page, then I have to get involved in scrolling up/down and it becomes difficult to find things efficiently.
    thanks!

    just a quick update and a general questions about applescripting with shell scripts...
    i attached the above folder action burst script to a folder, and have been dragging pdf files into it, one at a time.
    sometimes the script runs fine and the new files are created and the old pdf is deleted.  other times, there is a long delay between when I drop a pdf file into the folder and when the new files are created.  and sometimes nothing even happens at all (uaually if i dont wait for at least 30 seconds or so between dropping the files in the folder).  I also noticed that the window title text (area showing the folder name at the top of the finder window) becomes grayed out when the script is running and sometimes it remains grayed out for a few minutes after the script has run.
    could it be that the shell script just takes a really long time to work?  i am afraid to drop more than one file at a time as the last time I tried that the output was all wrong and I had to force quit processes and shut down. 

  • Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files

    GUIDE TO RUNNING EXTERNAL JOBS ON 10g WITH DBMS_SCHEDULER
    NOTE: Users using 11g should use the new method of specifying a credential which eliminates many of the issues mentioned in this note.
    This guide covers several common questions and problems encountered when using
    dbms_scheduler to run external jobs, either on Windows or on UNIX.
    What operating system (OS) user does the job run as ?
    External jobs which have a credential (available in 11g) run as the user
    specified in the credential. But for jobs without credentials including
    all jobs in 10gR1 and 10gR2 there are several cases.
    - On UNIX systems, in releases including and after 10.2.0.2 there is a file $ORACLE_HOME/rdbms/admin/externaljob.ora . All external jobs not in the SYS schema and with no credential run as the user and group specified in this file. This should be nobody:nobody by default.
    - On UNIX systems, in releases prior to 10.2.0.2 there was no "externaljob.ora" file. In this case all external jobs not in the SYS schema and with no credential run as the owner and group of the $ORACLE_HOME/bin/extjob file which should be setuid and setgid. By default extjob is owned by nobody:nobody except for oracle-xe where it is owned by oracle:oraclegroup and is not setuid/setgid.
    - On Windows, external jobs not in the SYS schema and with no credential run as the user that the OracleJobScheduler Windows service runs as. This service must be started before these jobs can run.
    - In all releases on both Windows and UNIX systems, external jobs in the SYS schema without a credential run as the oracle user.
    What errors are reported in SCHEDULERJOB_RUN_DETAILS views ?
    If a job fails, the first place to look for diagnostic information is the SCHEDULERJOB_RUN_DETAILS set of views. In 10gR2 and up the first 200 characters of the standard error stream is included in the additional_info column.
    In all releases, the error number returned by the job is converted into a
    system error message (e.g. errno.h on UNIX or net helpmsg on Windows) and that
    system error message is recorded in the additional info column. If there is no
    corresponding message the number is displayed.
    In 11g and up the error number returned by the job is additionally recorded in
    the error# column. In earlier releases 27369 would always be recorded in the
    error# column.
    Generic Issues Applicable to UNIX and Windows
    - The job action (script or executable) must return 0 or the job run will be marked as failed.
    - Always use the full pathname to executables and scripts.
    - Do not count on environment variables being set in your job. Make sure that the script or executable that your jobs runs sets all required environment variables including ORACLE_HOME, ORACLE_SID, PATH etc.
    - It is not recommended to pass in a complete command line including arguments as the action. Instead it is recommended to pass in only the path to and name of the executable and to pass in arguments as job argument values.
    - Scripts with special characters in the execution path or script name may give problems.
    - Ensure that the OS user your job runs as has the required privileges/permissions to run your job. See above for how to tell who the job runs as.
    - External job actions cannot contain redirection operators e.g. > < >> | && ||
    - In general try getting a simple external job working first e.g. /bin/echo or ipconfig.exe on Windows. Also try running the job action directly from the commandline as the OS user that the job will run as.
    Windows-specific Issues
    - The OracleJobScheduler Windows service must be started before external jobs will run (except for jobs in the SYS schema and jobs with credentials).
    - The user that the OracleJobScheduler Windows service runs as must have the "Log on as batch job" Windows privilege.
    - A batch file (ending in .bat) cannot be called directly by the Scheduler. Instead cmd.exe must be used and the name of the batch file passed in as an argument. For example
    begin
    dbms_scheduler.create_job('myjob',
       job_action=>'C:\WINDOWS\SYSTEM32\CMD.EXE',
       number_of_arguments=>3,
       job_type=>'executable', enabled=>false);
    dbms_scheduler.set_job_argument_value('myjob',1,'/q');
    dbms_scheduler.set_job_argument_value('myjob',2,'/c');
    dbms_scheduler.set_job_argument_value('myjob',3,'c:\temp\test.bat');
    dbms_scheduler.enable('myjob');
    end;
    /- In 10gR1 external jobs that wrote to standard output or standard error streams would sometimes return errors. Redirect to files or suppress all output and error messages when using 10gR1 to run external jobs.
    UNIX-specific Issues
    - When running scripts, make sure that the executable bit is set.
    - When running scripts directly, make sure that the first line of the script in a valid shebang line - starting with "#!" and containing the interpreter for the script.
    - In release 10.2.0.1, jobs creating a large amount of standard error text may hang when running (this was fixed in the first 10.2.0.2 patchset). If you are seeing this issue, redirect standard error to a file in your job. This issue has been seen when running the expdp utility which may produce large amounts of standard error text.
    - the user that the job runs as (see above section) must have execute access on $ORACLE_HOME/bin and all parent directories. If this is not the case the job may be reported as failed or hang in a running state. For example if your $ORACLE_HOME is /opt/oracle/db then you would have to make sure that
    chmod a+rx /opt
    chmod a+rx /opt/oracle
    chmod a+rx /opt/oracle/db
    chmod a+rx /opt/oracle/db/bin
    - On oracle-xe, the primary group of your oracle user (if it exists) must be dba before you install oracle-xe for external jobs to work. If you have an oracle user from a regular Oracle installation it may have the primary group set to oinstall.
    - On oracle-xe, the extjobo executable is missing so external jobs in the SYS schema will not work properly. This can be fixed by copying the extjob executable to extjobo in the same directory ($ORACLE_HOME/bin).
    - Check that correct permissions are set for external job files - extjob and externaljob.ora (see below)
    Correct permissions for extjob and externaljob.ora on UNIX
    There is some confusion as to what correct permissions are for external job related files.
    In 10gR1 and 10.2.0.1 :
    - rdbms/admin/externaljob.ora should not exist
    - bin/extjob should be setuid and setgid 6550 (r-sr-s---). It should be owned by the user that jobs should run as and by the group that jobs should run as.
    - bin/extjobo should have normal 755 (rwxr-xr-x) permissions and be owned by oracle:oraclegroup
    In 10.2.0.2 and higher
    - rdbms/admin/externaljob.ora file must must be owned by root:oraclegroup and be writable only by the owner i.e. 644 (rw-r--r--) It must contain at least two lines: one specifying the run-user and one specifying the run-group.
    - bin/extjob file must be also owned by root:oraclegroup but must be setuid i.e. 4750 (-rwsr-x---)
    - bin/extjobo should have normal 755 (rwxr-xr-x) permissions and be owned by oracle:oraclegroup
    In 11g and higher
    Same as 10.2.0.2 but additionally bin/jssu should exist with root setuid
    permissions i.e. owned by root:oraclegroup with 4750 (-rwsr-x---)
    Internal Error numbers for UNIX on 10.2.0.2 or 10.1.0.6 or higher
    If you are not using a credential and are using version 10.2.0.2 or higher or 10.1.0.6 or higher you may come across an internal error number. Here are the meanings for the internal error numbers.
    274661 - can't get owner of or permissions of externaljob.ora file
    274662 - not running as root or externaljob.ora file is writable by group or other or externaljob.ora file not owned by root (can't switch user)
    274663 - setting the group or effective group failed
    274664 - setting the user or effective user failed
    274665 - a user or group id was not changed successfully
    274666 - cannot access or open externaljob.ora file
    274667 - invalid run_user specified in externaljob.ora file
    274668 - invalid run_group specified in externaljob.ora file
    274669 - error parsing externaljob.ora file
    274670 - extjobo is running as root user or group

    Hi Ravi,
    Can you help me...
    Hi All,
    I planned to create a job to do rman backup daily at 04:00 AM.
    1. I created a program as follows
    BEGIN
    DBMS_SCHEDULER.CREATE_PROGRAM(
    program_name => 'rman_backup_prg',
    program_action => '/u02/rmanback/rman.sh',
    program_type => 'EXECUTABLE',
    comments => 'RMAN BACKUP');
    END;
    my rman script is
    #!/usr/bin/ksh
    export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
    export PATH=$PATH:/u01/app/oracle/product/10.2.0/db_1/bin
    /u01/app/oracle/product/10.2.0/db_1/bin/exp rman/cat@catdb file=/u02/rmanback/rm
    an_220108.dmp log=/u02/rmanback/rman_220108.log owner=rman statistics=none comp
    ress=n buffer=400000
    compress *.dmp
    exit
    2. I created a schedule as follows
    BEGIN
    DBMS_SCHEDULER.CREATE_SCHEDULE(
    schedule_name => 'rman_backup_schedule',
    start_date => SYSTIMESTAMP,
    end_date => '31-DEC-16 05.00.00 AM',
    repeat_interval => 'FREQ=DAILY; BYHOUR=4',
    comments => 'Every day at 4 am');
    END;
    3. I created ajob as follows.
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'rman_backup_job',
    program_name => 'rman_backup_prg',
    schedule_name => 'rman_backup_schedule',
    enabled=> true,
    auto_drop=> false
    END;
    While I am running the job I am getting the following error anybody help me.
    ORA-27369: job of type EXECUTABLE failed with exit code: Not owner
    ORA-06512: at "SYS.DBMS_ISCHED", line 150
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
    ORA-06512: at line 2
    If I removed "compress *.dmp" line in rman script it is working fine.
    /* additional Info from dba_scheduler_job_run_details as follows */
    ORA-27369: job of type EXECUTABLE failed with exit code: Not owner
    STANDARD_ERROR="
    Export: Release 10.2.0.3.0 - Production on Tue Jan 22 14:30:08 2008
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to: Oracle Database 10g Release 10.2.0.3.0 - Production
    Export"
    Regards,
    Kiran

  • Problem with the run_job,shell script with sqlldr

    Hi Gurus,
    I Created a job which calls the shell script and i understood from the other posting this job is going to execute with nobody,
    I had done the below testing
    Test 1) Shell script calls the SQL file, this SQL file executes the procedure.
    Test 2) Shell script calls the sqlldr command.
    When i execute the Test cases with , dbms_scheduler Run_job procedure, Test1 is success but Test2 was failed
    When i execute the Test cases with, logging into box with owner of the shell & both test cases are successful.
    Parent folder & Shell files are given with 777 permissions. & the Oracle db is version 10.2.0.1.0.
    Error:
    STANDARD_ERROR="SQL*Loader-522: lfiopn failed for file (*.log)"
    Please provide me your inputs its bit urgent Thanks a lot for your help.
    Edited by: 926769 on May 23, 2012 2:27 PM

    First of all let's look at your environment ... a totally unpatched version of software that is so old it is in desupport mode. You should upgrade to a fully supported version but, if you can't, at least to 10.2.0.5.
    That said without seeing any of your code, or a listing showing permissions on the directory and files, there is insufficient information from which to help you.
    Please post ALL information required for us to understand what you are doing an your environment.
    But before I decided that NOBODY was doing anything ... I'd shell out to the server from SQL*Plus using the HOST command and verify that permissions are as you believe them to be. There is every reason to believe SQL*Loader is having an issue with your file as identified.

  • Shell script execution from stored procedure

    I am working on a project thallt requires a shell script be executed upon the execution of a stored procedure with Oracle 10g. I have researched the matter, but there does not seem to be much out there on how to execute lines of UNIX commands by use of a stored procedure. If anybody has ever gotten this to work, any information would be appreciated. If the task is impossible, let me know, I just could not confirm that it was not something that could be done.

    A combination of things can help you out here - none of which are easy or particularily secure.
    1) From plain PL/SQL, you can call 'external procedures'. That is basically a DLL or .so that the listener can load on demand, and that external procedure (EXTPROC) can run whatever you need from the C program. C can, in turn, call a shell.
    This is fairly well documented, but be aware that 1/2 of the info is in the PL/SQL docco and the other half in the Networking docco.
    A fair bit of info is available in metalink as well - if you have access, simply search on extproc.
    2) You can call a Java stored procedure which in turn has hooks to the outside world. That will probably require a PL/SQL to Java wrapper to make it available in your environment. Oracle has been using this one successfully for a while.
    3) Write the script using UTL_FILE and have a daemon look for, and execute, the script.
    4) Since you are using 10g, use the new job scheduler. It has excellent capability to interact with the OS, and it is available as a PL/SQL package (DBMS_SCHEDULER). I find the interface a bit heavy, but that could be wrapped by a library tailored to your specific needs.
    Let us know what you decide to do in the end (and why) - it is an interesting topic.

  • Java and Shell Scripts

    I have created a java program that its main target is to read from a log file. The GUI has six buttons and its button has a script running each time the button is being hit. The results of the script are presented on a JTextArea automatically. So I have six buttons and six scripts. The problem is that the first time the program works fine. But if I click one button for the second time I get no results or wrong results. The scripts alone(when they work without the java program) work right.
    Is this a memory problem? How can I have the scripts with the java program work right together? I must say that each script needs 4-5 seconds to execute and immediately after the execution, the results, as I told before, are shown in a JTextArea. How can I solve the problem, so that I have the right results every time I click the buttons and not just for the first time?
    I need your ideas as soon as possible. :)))
    For connecting the java program and the shell scripts I use:
    Process proc = Runtime.getRuntime().exec("bash script ");
    OutputStream out = proc.getOutputStream();
    PrintWriter p = new PrintWriter(out);
    p.flush();     

    I think u must use process.waitFor() method .
    By this, u r sure that the said process shall complete.
    Also I would recommend new Instance/Thread for running each script.

  • Sample shell script - to run procedures and shell script

    Hi ,
    I would like run some procedures in one shell script which passing parameters as username/password@dbname.
    1. Execute proce1
    2.Execute proce3
    3.Execute proc4
    Can you please give some script/idea how we will create shell script . I am using SunSolaris Unix operating system.I would appreciate your help.
    Regards,
    Clark

    user10818198 wrote:
    I would like run some procedures in one shell script which passing parameters as username/password@dbname.
    1. Execute proce1
    2.Execute proce3
    3.Execute proc4
    At a very basic level, based on the information you have provided, your shell script would be something like this:
    sqlplus /nolog <<EOF
    connect username/password@dbname
    exec proce1;
    exec proce2;
    exec proce3;
    exit
    EOFBesides this, you could:
    (1) Add the shebang at the top, to specify the shell you are using, e.g. #!/bin/ksh for the Korn shell etc.
    (2) Ensure that "sqlplus" is recognized by the shell, by maybe running an "ora_env.sh" script that sets Oracle parameters. More likely, if you are using this Unix account for interaction with Oracle, then you may want to add the Oracle parameter information in your .profile or .bash_profile or .csh_profile etc. in the home directory.
    (3) Run a few sqlplus commands right before calling those stored procedures, if needed. For example, if you want to exit from sqlplus (and Oracle) if an error occurs while executing any procedure, then add this -
    whenever sqlerror exit 1Thus your script becomes:
    #!/bin/ksh
    # Ensure that Oracle parameters are set by this point
    sqlplus /nolog <<EOF
    connect username/password@dbname
    whenever sqlerror exit 1
    exec proce1;
    exec proce2;
    exec proce3;
    exit
    EOF(There are other settings as well; it really depends on your requirements.)
    Can you please give some script/idea how we will create shell script . I am using SunSolaris Unix operating system.
    How to create a shell script ? Well,
    (1) Save the commands shown above in a file, using your favorite text editor. Name the file "my_script.sh" or "<a_better_name>.sh" etc. (or maybe ".ksh" for the Korn shell - it's just a best practice, the shell doesn't really care.)
    (2) Make your script executable, like so -
    $ chmod 744 myscript.sh(3) And then execute it -
    $ ./myscript.sh- You could also execute the script in the current shell (as against a child shell) by doing this after Step (1):
    $ . myscript.shHope that helps.
    If there are specific questions, then post them here.
    isotope

Maybe you are looking for