8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Misc » Here

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

The Enterprise Manager Command Line Interface (EMCLI) allows you to script your Cloud Control setup, rather than using the Cloud Control console. This article describes how to manage jobs in Cloud Control using EMCLI, rather than using the web interface.

For more information see:

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.

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

Add Job

The create_job verb is used to add jobs. It expects an input file containing all the properties of the job to be created. The describe_job_type 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 get_job_types verb. Alternatively you can describe an existing job using the describe_job verb to get some inspiration.

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

Once you have a suitable property file, you can create a job using the create_job verb.

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

Display Jobs

The get_jobs verb is used to display jobs. There are a lot of variations, but here are some examples.

# 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;"

The available status IDs are displayed using the help verb. A section of the output for this verb is shown below.

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
...

Suspend/Resume Job

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

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}"

Remove Job

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

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}"

Help

The usage of the commands referenced in this article can displayed using the following commands.

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

You can also check out all the other job verbs in the Help Command Output.

emcli help

For more information see:

Hope this helps. Regards Tim...

Back to the Top.