无法在Oracle Scheduler作业中使用psexec64在远程Windows服务器上执行批处理文件

agxfikkp  于 2023-01-16  发布在  Oracle
关注(0)|答案(1)|浏览(142)
declare
      vname varchar(20) := 'DEMOJOB';
    BEGIN
      begin dbms_scheduler.drop_job (vname); exception when others then null; end ;
      dbms_scheduler.create_job(
        job_name => vname,
        job_type => 'EXECUTABLE',
        job_action => 'D:\Version_Start\PSTools\psexec64.exe \\server1 -u test-domain\usr1 -p Tes_@23 -i -d D:\Start_OC4J.bat',
        number_of_arguments => 0,
       enabled => FALSE); 
     dbms_scheduler.enable( vname);
 
   END;
  /

我得到的错误是ORA-27369:类型为EXECUTABLE的作业失败,退出代码为:功能不正确。

ruarlubt

ruarlubt1#

这不是你在调度器中运行一个有多个参数的程序的方式。你需要单独设置参数。例如,要运行一个旧的“exp”命令,你会这样做

SQL> exec DBMS_SCHEDULER.CREATE_JOB(JOB_NAME => 'CONNOR_JOB',JOB_TYPE => 'EXECUTABLE',JOB_ACTION =>'c:\oracle\product\12.1.0.2\bin\exp.exe', NUMBER_OF_ARGUMENTS => 4);

PL/SQL procedure successfully completed.

SQL> exec DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('CONNOR_JOB', 1, 'userid=connor/connor@np12');

PL/SQL procedure successfully completed.

SQL> exec DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('CONNOR_JOB', 2, 'file="c:\temp\dump.dmp"');

PL/SQL procedure successfully completed.

SQL> exec DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('CONNOR_JOB', 3, 'owner=scott');

PL/SQL procedure successfully completed.

SQL> exec DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('CONNOR_JOB', 4, 'log="c:\temp\CONNOR_JOB.log"');

PL/SQL procedure successfully completed.

SQL> exec DBMS_SCHEDULER.RUN_JOB(JOB_NAME => 'CONNOR_JOB', USE_CURRENT_SESSION => TRUE);

PL/SQL procedure successfully completed.

SQL> select job_name, status from user_scheduler_job_run_details order by log_date;

JOB_NAME                       STATUS
------------------------------ ------------------------------
CONNOR_JOB                     SUCCEEDED

在您的情况下,我建议存储一个CMD文件,其中包含您需要的所有部分,然后调用它。这样做可以使事情变得简单。如果您需要动态创建CMD脚本,只需使用UTL_FILE来编写它。

相关问题