Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Help getting an EXECUTABLE to run under DBMS_SCHEDULER

Re: Help getting an EXECUTABLE to run under DBMS_SCHEDULER

From: Andy Hassall <andy_at_andyh.co.uk>
Date: Wed, 21 Dec 2005 17:00:52 +0000
Message-ID: <pe2jq1hhbholr5g7e6ajidj2306nj1ud6e@4ax.com>


On 21 Dec 2005 06:18:08 -0800, "GeoPappas" <PappasG_at_gmail.com> wrote:

>The following command (which just executes the date command) says that
>it completes successfully:
>
>BEGIN
>DBMS_SCHEDULER.CREATE_JOB(
> job_name => 'test',
> job_type => 'EXECUTABLE',
> job_action => '/usr/bin/date',
> enabled => TRUE
>);
>END;
>/
>
>But the following command (which appends the output of the date command
>to a file in the tmp directory) fails:
>
>BEGIN
>DBMS_SCHEDULER.CREATE_JOB(
> job_name => 'test',
> job_type => 'EXECUTABLE',
> job_action => '/usr/bin/date>>/tmp/date.log',
> enabled => TRUE
>);
>END;
>/
>
>The error that is thrown is "ORA-27369: job of type EXECUTABLE failed
>with exit code: No such file or directory".
>
>I have tried this without the existence of a date.log file and with the
>existence of a date.log file in the /tmp directory. Both commands fail
>with the same error (above).

 Probably because Oracle is (quite rightly) taking the job_action column literally, and looking for a file named '/usr/bin/date>>/tmp/date.log' to run - which doesn't exist.

 >> as append to file is a shell construct, whereas this is just running an executable direct.

 Consider the following which does work (had to adjust paths for my system as date is in /bin on mine, not /usr/bin) - this runs it through a shell and adds the rest as arguments:

BEGIN

    DBMS_SCHEDULER.CREATE_JOB(
    	job_name	        => 'test',
    	job_type	        => 'EXECUTABLE',
    	job_action	        => '/bin/sh',
    	number_of_arguments => 2

    );

    DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (

       job_name          => 'test',
       argument_position => 1,
       argument_value    => '-c'

    );

    DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (

       job_name          => 'test',
       argument_position => 2,
       argument_value    => '/bin/date>>/tmp/date.log'
    );     

    DBMS_SCHEDULER.ENABLE('test');
END;
/

-- 
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Received on Wed Dec 21 2005 - 11:00:52 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US