troubleshoot - scheduler job not running
sqlplus Scott/tiger
-- list scheduler job
set lines 120
col SCHEDULE_NAME format a25
col SCHEDULE_TYPE form a10
prompt from dba_scheduler_jobs
prompt =============
select job_name, schedule_name, schedule_type, enabled from dba_scheduler_jobs where owner=upper('&schema') ;
-NOTE in the enabled column - TRUE means working, FALSE means not working
-- identify scheduler running jobs
select
rj.job_name,
s.username,
s.sid,
s.serial#,
p.spid,
s.lockwait,
s.logon_time
from
user_scheduler_running_jobs rj,
v$session s,
v$process p
where
rj.session_id = s.sid
and
s.paddr = p.addr
order by
rj.job_name
;
SELECT max(log_date) FROM user_scheduler_job_run_details where job_name='SCH_JOB_NAME_HERE''
-- to kill by sid
select 'alter system kill session '||chr(39)||s.sid||','||s.serial#||chr(39)||';'
from user_scheduler_running_jobs rj,
v$session s,
v$process p
where rj.session_id = s.sid
and s.paddr = p.addr
order by rj.job_name;
-- to kill by by pid
select 'kill -9 '||p.spid
from
user_scheduler_running_jobs rj,
v$session s,
v$process p
where
rj.session_id = s.sid
and
s.paddr = p.addr
order by
rj.job_name
;
useful commands
exec dbms_scheduler.disable('SCH_JOB_NAME_HERE');
exec dbms_scheduler.enable('"SCH_JOB_NAME_HERE"');
exec dbms_scheduler.stop_job('SCH_JOB_NAME_HERE');