Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to view Oracle job logs

mohitanchliaDec 17 2008 — edited Apr 22 2009
Oracle 10g:

I have following job:

procedure create_or_replace_job as
begin
begin
dbms_scheduler.drop_job(job_name => merge_job_name);
exception
when others then
/* ignore */
commit;
end;
dbms_scheduler.create_job(job_name => merge_job_name,
job_type => 'STORED_PROCEDURE',
job_action => merge_proc_name,
start_date => to_timestamp('01-Jan-1970 ' || merge_job_time,
'DD-Mon-RRRR HH24:MI:SS'),
repeat_interval => 'FREQ = DAILY; INTERVAL = 1');
commit;
end;
---

But I want to see when job ran and if there were any errors.

Comments

Aman....
user628400 wrote:
Oracle 10g:

But I want to see when job ran and if there were any errors.
You may want to check scheduler* views from doc for this. For example,
[dba_scheduler_job_log|http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2047.htm#i1587038]
[dba_scheduler_job_run_details|http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2048.htm#i1587156]
HTH
Aman....
591186
all_scheduler_job_log will give you some information.
LKBrwn_DBA

Would be easy if you use Enterprise Manager.
Otherwise you need to look at:

ALL_SCHEDULER_JOB_LOG view :p
247514
Did you check DBA view dba_scheduler_job_run_details ?

lol , I answered a quick phone call before I hit submit button, can't believe how many replies were posted during the interim.

Edited by: yingkuan on Dec 17, 2008 9:23 AM
Aman....
yingkuan wrote:
lol , I answered a quick phone call before I hit submit button, can't believe how many replies were posted during the interim.
That's why I was just sitting quietly and watching them flying all over :-).
Aman....
mohitanchlia
What could be the reason if I don't see anything in the logs? But I do know that the job got executed.
Aman....
user628400 wrote:
What could be the reason if I don't see anything in the logs? But I do know that the job got executed.
It may be that the job's log level is not properly set.
http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/scheduse002.htm#CHDGIDFD
HTH
Aman....
mohitanchlia
I am looking at how long it took for "GATHER_STATS_JOB" to run also when it started and when it ended. But none of the views that I queried give me that detail. I tried:

select * from dba_scheduler_job_run_details where job_name = 'GATHER_STATS_JOB' order by log_id desc

LOG_ID	LOG_DATE	OWNER	JOB_NAME	JOB_SUBNAME	STATUS	ERROR#	REQ_START_DATE	ACTUAL_START_DATE	RUN_DURATION	INSTANCE_ID	SESSION_ID	SLAVE_PID	CPU_USED	ADDITIONAL_INFO	
1741		SYS	GATHER_STATS_JOB	<NULL>	SUCCEEDED	0	<NULL>			1	2316,20537	25785		<NULL>	
select * from dba_scheduler_jobs

OWNER	JOB_NAME	JOB_SUBNAME	JOB_CREATOR	CLIENT_ID	GLOBAL_UID	PROGRAM_OWNER	PROGRAM_NAME	JOB_TYPE	JOB_ACTION	NUMBER_OF_ARGUMENTS	SCHEDULE_OWNER	SCHEDULE_NAME	SCHEDULE_TYPE	START_DATE	REPEAT_INTERVAL	EVENT_QUEUE_OWNER	EVENT_QUEUE_NAME	EVENT_QUEUE_AGENT	EVENT_CONDITION	EVENT_RULE	END_DATE	JOB_CLASS	ENABLED	AUTO_DROP	RESTARTABLE	STATE	JOB_PRIORITY	RUN_COUNT	MAX_RUNS	FAILURE_COUNT	MAX_FAILURES	RETRY_COUNT	LAST_START_DATE	LAST_RUN_DURATION	NEXT_RUN_DATE	SCHEDULE_LIMIT	MAX_RUN_DURATION	LOGGING_LEVEL	STOP_ON_WINDOW_CLOSE	INSTANCE_STICKINESS	RAISE_EVENTS	SYSTEM	JOB_WEIGHT	NLS_ENV	SOURCE	DESTINATION	COMMENTS	FLAGS	
SYS	GATHER_STATS_JOB	<NULL>	SYS	<NULL>	<NULL>	SYS	GATHER_STATS_PROG	<NULL>	<NULL>	<NULL>	SYS	MAINTENANCE_WINDOW_GROUP	WINDOW_GROUP	<NULL>	<NULL>	<NULL>	<NULL>	<NULL>	<NULL>	<NULL>	<NULL>	AUTO_TASKS_JOB_CLASS	TRUE	FALSE	TRUE	SCHEDULED	3	125	<NULL>	0	<NULL>	0			<NULL>	<NULL>	<NULL>	RUNS	TRUE	TRUE	<NULL>	TRUE	1	NLS_LANGUAGE='AMERICAN' NLS_TERRITORY='AMERICA' NLS_CURRENCY='$' NLS_ISO_CURRENCY='AMERICA' NLS_NUMERIC_CHARACTERS='.,' NLS_CALENDAR='GREGORIAN' NLS_DATE_FORMAT='DD-MON-RR' NLS_DATE_LANGUAGE='AMERICAN' NLS_SORT='BINARY' NLS_TIME_FORMAT='HH.MI.SSXFF AM' NLS_TIMESTAMP_FORMAT='DD-MON-RR HH.MI.SSXFF AM' NLS_TIME_TZ_FORMAT='HH.MI.SSXFF AM TZR' NLS_TIMESTAMP_TZ_FORMAT='DD-MON-RR HH.MI.SSXFF AM TZR' NLS_DUAL_CURRENCY='$' NLS_COMP='BINARY' NLS_LENGTH_SEMANTICS='BYTE' NLS_NCHAR_CONV_EXCP='FALSE'	<NULL>	<NULL>	Oracle defined automatic optimizer statistics collection job	21074010	
select * from dba_schedular_schedules

OWNER	SCHEDULE_NAME	SCHEDULE_TYPE	START_DATE	REPEAT_INTERVAL	EVENT_QUEUE_OWNER	EVENT_QUEUE_NAME	EVENT_QUEUE_AGENT	EVENT_CONDITION	END_DATE	COMMENTS	
SYS	DAILY_PURGE_SCHEDULE	CALENDAR	<NULL>	freq=daily;byhour=3;byminute=0;bysecond=0	<NULL>	<NULL>	<NULL>	<NULL>	<NULL>	<NULL>	
591186
Post the output of the below:
SELECT job_name, state FROM dba_scheduler_jobs WHERE job_name='GATHER_STATS_JOB';

select job_name, job_type, program_name, schedule_name, job_class from dba_scheduler_jobs where job_name = 'GATHER_STATS_JOB';

The actual_start_date and the run_duration will give you how long did it run.

SQL> desc dba_scheduler_job_run_details
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 LOG_ID                                             NUMBER
 LOG_DATE                                           TIMESTAMP(6) WITH TIME ZONE
 OWNER                                              VARCHAR2(30)
 JOB_NAME                                           VARCHAR2(65)
 JOB_SUBNAME                                        VARCHAR2(65)
 STATUS                                             VARCHAR2(30)
 ERROR#                                             NUMBER
 REQ_START_DATE                                     TIMESTAMP(6) WITH TIME ZONE
 ACTUAL_START_DATE                                  TIMESTAMP(6) WITH TIME ZONE
 RUN_DURATION                                       INTERVAL DAY(3) TO SECOND(0)
 INSTANCE_ID                                        NUMBER
 SESSION_ID                                         VARCHAR2(30)
 SLAVE_PID                                          VARCHAR2(30)
 CPU_USED                                           INTERVAL DAY(3) TO SECOND(2)
 ADDITIONAL_INFO                                    VARCHAR2(4000)
mohitanchlia
As you can see from my post above I tried that but it columns are empty. This is the jbos that Oracle runs every night.
rbglossip
It should be there.
SQL> select actual_start_date
  2       , actual_start_date + run_duration end_date
  3    from dba_scheduler_job_run_details
  4   where log_id = (select max(log_id)
  5                     from dba_scheduler_job_run_details
  6                    where job_name = 'GATHER_STATS_JOB');

ACTUAL_START_DATE
------------------------------------------------------------
END_DATE
------------------------------------------------------------
21-APR-09 10.00.02.244907 PM -04:00
21-APR-09 10.00.36.244907000 PM -04:00
Your output is a bit hard to read. Can you try the query above in SQL*Plus?
591186
oh. that was fast. I was just about to post the same... :D

may be, my browser was thinking :)

Edited by: Anantha on Apr 22, 2009 4:25 PM
rbglossip
Not too fast. Two replies posted while I was typing it ;)
591186
Post the output of:
SELECT job_name, state FROM dba_scheduler_jobs WHERE job_name='GATHER_STATS_JOB';

select job_name, job_type, program_name, schedule_name, job_class from dba_scheduler_jobs where job_name = 'GATHER_STATS_JOB';
mohitanchlia
SELECT job_name, state FROM dba_scheduler_jobs WHERE job_name='GATHER_STATS_JOB';

JOB_NAME	STATE	
GATHER_STATS_JOB	SCHEDULED	

select job_name, job_type, program_name, schedule_name, job_class from dba_scheduler_jobs where job_name = 'GATHER_STATS_JOB';

JOB_NAME	JOB_TYPE	PROGRAM_NAME	SCHEDULE_NAME	JOB_CLASS	
GATHER_STATS_JOB	<NULL>	GATHER_STATS_PROG	MAINTENANCE_WINDOW_GROUP	AUTO_TASKS_JOB_CLASS	

select actual_start_date
       , actual_start_date + run_duration end_date
    from dba_scheduler_job_run_details
   where log_id = (select max(log_id)
from dba_scheduler_job_run_details
                    where job_name = 'GATHER_STATS_JOB');


ACTUAL_START_DATE	END_DATE	

--above returned empty fields
rbglossip
What's the full version number?

What's the output of this query?
select log_date
from dba_scheduler_job_run_details
   where log_id = (select max(log_id)
from dba_scheduler_job_run_details
                    where job_name = 'GATHER_STATS_JOB');
Are the queries being executed from SQL*Plus?
mohitanchlia
10.2.0.4: as I mentioned in my previous post that the output of that query returns empty columns.
rbglossip
output of that query returns empty columns.
That's quite odd. I would think the log_date column would always be populated. Can you run the following?
select count(*) from dba_scheduler_job_run_details;

select count(*) from dba_scheduler_job_run_details where log_date is null;

select count(*) from dba_scheduler_job_run_details where log_date is not null;
Is the SQL*Plus version 10.2.0.4 as well?
mohitanchlia
It seems to be working now when I pointed to correct version of sqlplus. I am not sure why I was seeing empty columns earlier?
rbglossip
They're TIMESTAMP columns. Older versions of SQL*Plus probably can't handle them.
1 - 20
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 20 2009
Added on Dec 17 2008
20 comments
61,680 views