This discussion is archived
1 2 Previous Next 15 Replies Latest reply: Jul 17, 2012 9:52 AM by Joe Upshaw RSS

What's Wrong with this External Tar Job?

Joe Upshaw Journeyer
Currently Being Moderated
I am attempting to run this command:

tar cfvz /o498/risktst/maps/output/options/C4B7DE34BD914EEDE040030A1C410D17.tar.gz /o498/risktst/maps/output/options/*C4B7DE34BD914EEDE040030A1C410D17.csv
BEGIN
 
DBMS_SCHEDULER.CREATE_JOB
    (
       job_name        => 'RISKDM2.ZIP_INPUT_FILES'
      ,job_type        => 'EXECUTABLE'
      ,job_action            => '/bin/tar'
      ,number_of_arguments   => 3
      ,start_date            => SYSTIMESTAMP ); 
 
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(
                                    job_name            =>  'RISKDM2.ZIP_INPUT_FILES',
                                    argument_position   => 1, 
                                    argument_value      => 'cfvz' );   
 
 
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(
                                    job_name            => 'RISKDM2.ZIP_INPUT_FILES',
                                    argument_position   => 2, 
                                    argument_value      => '/o498/risktst/maps/output/options/C4B7DE34BD914EEDE040030A1C410D17.tar.gz'); 
 
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(
                                        job_name            => 'RISKDM2.ZIP_INPUT_FILES', 
                                        argument_position   => 3, 
                                        argument_value      => '/o498/risktst/maps/output/options/*C4B7DE34BD914EEDE040030A1C410D17.csv');      
 
 
END;
/
Actually the GUID part, i.e. "C4B7DE34BD914EEDE040030A1C410D17" gets passed in as a argument to the function but, even running the above, literal commands, the job fails with:

ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
STANDARD_ERROR="/bin/tar: Removing leading `/' from member names
/bin/tar: /o498/risktst/maps/output/options/*C4B7DE34BD914EEDE040030A1C410D17.csv: Cannot stat: No such file or directory
/bin/tar: Error exit delayed "

I can cut and paste the arguments directly from the scheduler arguments view in an OS command window and it works fine. Also, I have a very similar, two-argument job for gzip, that is working fine as well.

Based on the error, it looks as if Oracle is sending the arguments in the wrong order....like the "/o498/risktst/maps/output/options/*C4B7DE34BD914EEDE040030A1C410D17.csv" part is being passed in argument position 2. (In DBA_SCHEDULER_JOB_ARGS they are listed in the correct, 1,2,3 order as specified above.

Thanks in Advance for Any Help (been stuck on this for hours sigh),

-Joe
  • 1. Re: What's Wrong with this External Tar Job?
    BrianP Journeyer
    Currently Being Moderated
    Oracle version and host OS?

    I see 23 MOS docs referencing ORA-27369 and DBMS_SCHEDULER jobs, and 9 docs for "no such file or directory" and DBMS_SCHEDULER. Could be several different things... this isn't something I use, but does your gzip job also use a wildcard? I'm wondering if you might need to backslash-escape the '*' in the path.

    Edited by: BrianP on Jul 16, 2012 12:45 PM
  • 2. Re: What's Wrong with this External Tar Job?
    Joe Upshaw Journeyer
    Currently Being Moderated
    Brian, I looked at several of the first group...they all seemed to apply to permissions on shell script to be executed so; I didn't think it applied. I did, just now, find one regarding the permissions on the externaljob.ora file. I will try changing that.

    Thanks for responding, I will let you know how it goes.

    So ver odd that /bin/gzip would not have this problem and /bin/tar would if this is really the issue....

    -Joe
  • 3. Re: What's Wrong with this External Tar Job?
    Joe Upshaw Journeyer
    Currently Being Moderated
    I applied all of the recommended permissions changes from Doc ID: 391820.1. Did not help.

    Don't suppose you could recommend anything specific to try?

    Of course, this is the very last step that needs to work. LOL.

    Thanks,

    -Joe
  • 4. Re: What's Wrong with this External Tar Job?
    RnR Pro
    Currently Being Moderated
    Hi Joe,

    It looks like you are relying on shell fileglobbing to work but that dbms_scheduler executable jobs do not support file globbing (e.g. /tmp/*txt is a fileglob) .

    If you turned this into a shell script which accepted the same arguments and then passed the arguments to tar I think that might work.

    A shell script gives you flexibility in several other ways too.

    Thanks,
    Ravi.
  • 5. Re: What's Wrong with this External Tar Job?
    BrianP Journeyer
    Currently Being Moderated
    RnR's suggestion would be mine as well; if you can change the job to call a shell script that does everything you need it should just work. It's also easier to keep shell scripts in source control vs scheduler jobs.
  • 6. Re: What's Wrong with this External Tar Job?
    Joe Upshaw Journeyer
    Currently Being Moderated
    I can certainly do that but, I think I am missing some subtlety here. I will still need to pass the same arguments to the shell script.

    At any rate, I did create the shell script:
    #!/bin/bash
    tar $1 $2 $3
    Works just fine from the command line. I did note that you have to wrap the last argument (the one containing the wildcard "*") in doubhle quotes which was done.
    DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(
    job_name => 'RISKDM2.ZIP_INPUT_FILES', 
    argument_position => 3, 
    argument_value => '"/o498/risktst/maps/output/options/*C4B7DE34BD914EEDE040030A1C410D17.csv"'); 
    So, as usual, works just fine from the command line.
    ./tar_options.sh cfvz /o498/risktst/maps/output/options/C4B7DE34BD914EEDE040030A1C410D17.tar.gz "/o498/risktst/maps/output/options/*C4B7DE34BD914EEDE040030A1C410D17.csv"
    Works like a charm.

    Try it from Scheduler job and get:

    ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
    STANDARD_ERROR="/bin/tar: Removing leading `/' from member names
    /bin/tar: /o498/risktst/maps/output/options/*C4B7DE34BD914EEDE040030A1C410D17.csv: Cannot stat: No such file or directory
    /bin/tar: /o498/risktst/maps/"

    -Joe
  • 7. Re: What's Wrong with this External Tar Job?
    BrianP Journeyer
    Currently Being Moderated
    Time to add some debug logging to the shell script then to make sure the script is being called the way you want. Stick something like:
    echo "called as |$0| |$1| |$2| |$3|" >> /tmp/tar_options.log
    into the shell script before the call to tar, run it by hand and through dbms_scheduler, then compare the log entries.

    It looks to me like tar is receiving a literal * (like it's being called with single quotes, perhaps even with embedded double quotes).

    Compare:
    % ls S*
    SAPcheck_partitioned_tables.sql  Space_IndexCompression_CBOStatistics.txt
    % ./a.sh cvfz foo.tar S*
    SAPcheck_partitioned_tables.sql
    % ./a.sh cvfz foo.tar "S*"
    SAPcheck_partitioned_tables.sql
    Space_IndexCompression_CBOStatistics.txt
    % ./a.sh cvfz foo.tar 'S*'
    SAPcheck_partitioned_tables.sql
    Space_IndexCompression_CBOStatistics.txt
    % ./a.sh cvfz foo.tar '"S*"'
    tar: "S*": Cannot stat: No such file or directory
    tar: Error exit delayed from previous errors
    With log entries:
    called as |./a.sh| |cvfz| |foo.tar| |SAPcheck_partitioned_tables.sql|    # shell globbed it to one file
    called as |./a.sh| |cvfz| |foo.tar| |S*|         # tar globbed it to all files
    called as |./a.sh| |cvfz| |foo.tar| |S*|         # tar globbed it to all files
    called as |./a.sh| |cvfz| |foo.tar| |"S*"|      # tar looked for literal S* filename and failed
  • 8. Re: What's Wrong with this External Tar Job?
    Joe Upshaw Journeyer
    Currently Being Moderated
    Brian,

    Thanks.

    I am starting to despair. That is exactly what I was trying to do (capture the arguments).

    Now the script is simply:
    #!/bin/bash
    
    echo $1 > first_arg.log
    echo $2 > second_arg.log
    echo $3 > third_arg.log
    I pre-created all those log files and set them all with chmod 777 (Wide Open!).

    Then, I try to run it and get this nonsense:

    ORA-27369: job of type EXECUTABLE failed with exit code: Operation not permitted
    STANDARD_ERROR="/o498/risktst/maps/output/options/tar_options.sh: line 3: first_arg.log: *Permission denied*
    /o498/risktst/maps/output/options/tar_options.sh: line 4: second_arg.log: *Permission denied*
    /o498/risktst/map"

    Based on the fact that it never mentions third_arg.log, I suspect that my original suspicion is correct, i.e. Oracle is not passing the arguments as specified but, I can't prove it.

    -Joe
  • 9. Re: What's Wrong with this External Tar Job?
    BrianP Journeyer
    Currently Being Moderated
    It looks to me like the stderr output is being truncated (based on the incomplete line at the end, "/o498/risktst/map") so it may actually be hitting the third arg even if it doesn't look like it.

    Take a look at the contents of $ORACLE_HOME/rdbms/admin/externaljob.ora. There should be "run_user" and "run_group" lines in that file.

    I just checked two of my DBs and run_user/run_group are both set to "nobody". If you're just using "first_arg.log" as the logfile (without a fully qualified path), it's going to have user nobody try to create/edit those files in some default directory used by dbms_scheduler (probably $ORACLE_HOME/rdbms/admin but I'm not sure). User nobody may have 777 write permission to the files, but without at least execute permission all the way up the directory path to /, it won't be able to get to them.

    Make sure there's an appropriate user/group set in externaljob.ora -- maybe just use oracle/dba for testing, then see how it goes. And try using a full path for the arg log files to make sure it's writing where you think it is.

    Also, if you're using NFS for any of these paths, that could confuse things, especially if your run_user is set to something like root.

    Edited by: BrianP on Jul 17, 2012 7:38 AM (added line about NFS)
  • 10. Re: What's Wrong with this External Tar Job?
    User286067 Journeyer
    Currently Being Moderated
    Joe,

    if scheduler external jobs have a problem with fileglob, you can perhaps take a longer route especially since in your case the filenames will change for every execution.

    1. using utl_file create a shell script dynamically in the desired directory.
    2. once you close the file, pass on that script name to a external job which executes /bin/bash with one argument ... the file you created in step 1 along with path.
    3. since there will be only one argument, order of arguments won't matter.

    Granted it should work directly through external job interface, but this is one workaround that you might want to consider if scheduler keeps on barfing.

    Raj
  • 11. Re: What's Wrong with this External Tar Job?
    Joe Upshaw Journeyer
    Currently Being Moderated
    I see what you are suggesting...one dumb question...how do I set the exec permission on the shell script file when I create it?
  • 12. Re: What's Wrong with this External Tar Job?
    User286067 Journeyer
    Currently Being Moderated
    hence i suggested to call /bin/bash $1 ... where $1 is your script file you wrote using utl_file. so your external job will actually call /bin/bash with one argument, the file you created with full path. make sure it is in a directory that has rx permissions for Oracle.

    Edited by: rjamya on Jul 17, 2012 8:16 AM
  • 13. Re: What's Wrong with this External Tar Job?
    Joe Upshaw Journeyer
    Currently Being Moderated
    Well, got the darned thing working.

    Edited $OH/rdbms/admin/externaljob.ora and set

    run_user = oracle
    run_group = dba

    (reset ownership and permissions after edit)

    and the shell script version is now working with the three passed arguments. Oddly, I had to remove the double quotes that were added to the third argument earlier.

    The original version still does not work but, this, I can live with.

    Thanks so much for all the help.

    -Joe
  • 14. Re: What's Wrong with this External Tar Job?
    BrianP Journeyer
    Currently Being Moderated
    Hi Joe,

    I'm still curious how your gzip job worked -- what was in externaljob.ora before you changed it? It does seem like it should have had the exact same problems, unless you were using different directories with looser permissions.
1 2 Previous Next

Legend

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