DBA Hub

📋Steps in this guide1/6

EMCLI : Manage Jobs using Enterprise Manager Command Line Interface (Cloud Control)

This article describes how to manage jobs in Enterprise Manager Cloud Control using EMCLI, rather than using the web interface.

oracle miscconfigurationintermediate
by OracleDba
13 views
1

Setup

You can perform these actions from anywhere with an EMCLI client , but for this example we're going to use the EMCLI client on the Cloud Control server. We use the following commands to connect to the OMS and sync the EMCLI client.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
unset SSH_ASKPASS
export OMS_HOME=/u01/app/oracle/middleware
export AGENT_HOME=/u01/app/oracle/agent/agent_inst
alias emcli='${OMS_HOME}/bin/emcli'

emcli login -username=sysman
emcli sync
2

Add Job

The verb is used to add jobs. It expects an input file containing all the properties of the job to be created. The verb displays a blank properties file for a specific job type, which you can fill in yourself. The available job types are displayed using the verb. Alternatively you can describe an existing job using the verb to get some inspiration. Once you have a suitable property file, you can create a job using the verb.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
emcli get_job_types

emcli describe_job_type -type=RMANScript > /tmp/property_file.txt

emcli describe_job -name="MY_JOB" -owner="SYSMAN" > /tmp/property_file.txt

emcli create_job -input_file="property_file:/tmp/property_file.txt"
3

Display Jobs

The verb is used to display jobs. There are a lot of variations, but here are some examples. The available status IDs are displayed using the verb. A section of the output for this verb is shown below.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# All jobs.
emcli get_jobs

# All scheduled jobs.
emcli get_jobs \
  -status_ids="1;"

# All suspended jobs.
emcli get_jobs \
  -status_ids="6;"

export JOB_NAME="MY_JOB"
export JOB_OWNER="SYSMAN"

# Specific scheduled job.
emcli get_jobs \
  -name="${JOB_NAME}" \
  -owner="${JOB_OWNER}" \
  -status_ids="1;"

# Specific suspended job.
emcli get_jobs \
  -name="${JOB_NAME}" \
  -owner="${JOB_OWNER}" \
  -status_ids="6;"

emcli help get_jobs

...
    -status_ids
      List of numeric status IDs to use as the output filters.
      The numeric codes for all possible job statuses are as follows:
          SCHEDULED=1
          EXECUTING(Running)=2
          ABORTED(Error)=3
          FAILED=4
          COMPLETED(Successful)=5
          SUSPENDED_USER=6
          SUSPENDED_AGENT_DOWN=7
          STOPPED=8
          SUSPENDED_LOCK=9
          SUSPENDED_EVENT=10
          SUSPENDED_BLACKOUT=11
          STOP_PENDING=12
          SUSPEND_PENDING=13
          QUEUED=15
          SKIPPED=18
          REASSIGNED=20
          MISSING_CREDENTIALS=21
          ACTION_REQUIRED=22
          TARGET_NOT_READY=26
...
4

Suspend/Resume Job

The and verbs suspend and resume jobs respectively. All the filters are optional, so you can target all jobs, or specific jobs.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
JOB_NAME="MY_JOB"
JOB_OWNER="SYSMAN"
JOB_TYPE="RMANScript"

# Suspend all RMAN jobs.
emcli suspend_job \
  -type="${JOB_TYPE}"

# Suspend all jobs for a specific user.
emcli suspend_job \
  -owner="${JOB_OWNER}"

# Suspend specific job.
emcli suspend_job \
  -name="${JOB_NAME}"

# Resume all RMAN jobs.
emcli resume_job \
  -type="${JOB_TYPE}"

# Resume all jobs for a specific user.
emcli resume_job \
  -owner="${JOB_OWNER}"

# Resume specific job.
emcli resume_job \
  -name="${JOB_NAME}"
5

Remove Job

The verb is used to remove jobs. A job can only be removed if it is stopped, which is achieved using the verb.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
JOB_NAME="MY_JOB"
JOB_OWNER="SYSMAN"

emcli stop_job \
  -name="${JOB_NAME}" \
  -owner="${JOB_OWNER}"

emcli delete_job \
  -name="${JOB_NAME}" \
  -owner="${JOB_OWNER}"
6

Help

The usage of the commands referenced in this article can displayed using the following commands. You can also check out all the other job verbs in the Help Command Output . For more information see: - EMCLI : All Articles Hope this helps. Regards Tim...

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
emcli help get_job_types
emcli help describe_job_type 
emcli help describe_job 
emcli help create_job 
emcli help get_jobs
emcli help suspend_job
emcli help resume_job
emcli help stop_job
emcli help delete_job

emcli help

Comments (0)

Please to add comments

No comments yet. Be the first to comment!