暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle Scheduler作业继续运行,但设置为在240分钟/4小时后停止

askTom 2017-08-07
515

问题描述

嗨,

尽管他们已将最大作业持续时间设置为240分钟/4小时,但Oracle Scheduler作业继续运行超过15小时,直到他们将其杀死。我们如何使这项工作在最大工作持续时间之后停止一次?

我已经通过OEM上的Oracle调度程序进行了设置。它显示在dba_scheduler_jobs中,但不会停止作业。因此,为什么它不能停止工作。

开始
dbms_scheduler.create_job('"GATHERSTATS_OSMCORE_SCHEMA"',
job_type =>'可执行',job_action =>
'c:\ windows \ system32 \ cmd.exe'
,参数编号 =>2,
开始日期 => 到 _ 时间戳 _ tz ('2017年6月20日美国/纽约上午12.00.00.000000000
,'dd-MON-RRRR HH.MI.SSXFF AM TZR','nls_date_language = english '),repeat_interval =
>
'FREQ = 每周; BYDAY = SUN;BYHOUR = 12;BYMINUTE = 0;BYSECOND = 0'
,end_date =>NULL,
job_class =>'"DEFAULT_JOB_CLASS"',enabled =>FALSE,auto_drop =>FALSE,comments =>
'Gatherstats_ossmcere_schema'
);
dbms_scheduler.set_attribute('"GATHERSTATS_OSMCORE_SCHEMA"','最大运行持续时间','
000 04:00:00);
dbms_scheduler.set_attribute('"GATHERSTATS_OSMCORE_SCHEMA"','raise_events',36);
提交;
结束;


谢谢,

专家解答

从文档中:

"max_run_duration

This attribute specifies the maximum amount of time that the job should be allowed to run. Its datatype is INTERVAL DAY TO SECOND. If this attribute is set to a non-zero and non-NULL value, and job duration exceeds this value, the Scheduler raises an event of type JOB_OVER_MAX_DUR. It is then up to your event handler to decide whether or not to allow the job to continue."


因此,我们正在做的就是监视作业,并在长时间运行时引发job_over_max_dur事件。你可以创建一个工作来响应这个事件,采取任何你想做的行动,例如

begin dbms_scheduler.add_event_queue_subscriber('myagent'); end;

begin
dbms_scheduler.create_job(
  'killer',
  job_action=>'...appropriate killing behaviour...',
  event_condition =>
  'tab.user_data.object_name = ''GATHERSTATS_OSMCORE_SCHEMA'' and
  tab.user_data.event_type = ''JOB_OVER_MAX_DUR''',
  queue_spec =>'sys.scheduler$_event_queue,myagent',
  enabled=>true);
end;
复制


「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论