Working with OS Command Jobs

In a OS Command job, you specify a Command Type (Command or Script). The command or script specified will be executed against each target specified in the target list for the job. It will be executed by the Management Agent for each of those targets. The value specified in the OS Script field will be used as stdin for the specified command.

If you want to run a specific command, you can enter the full command in the Command field, for example:

/bin/df -k /private

When shell commands are used, ensure that the shell itself is invoked as part of the command in the Command field and that the command is entered in the OS Script field. In the following example, the Command field, the /bin/sh in the Command field invokes the Bourne shell, and then the ls -la and redirection part of the command in the OS Script field is executed:

Command field: /bin/sh

OS Script field: ls -la /tmp > /tmp/foobar.out

If two consecutive shell commands need to be executed, the shell must be invoked in the Command field and the commands themselves in the OS Script field. In other words, you would specify this as follows:

Command field: /bin/sh

OS Script field: sleep 3; ls

If you want to run a script, you can do this in a couple of ways:

  1. Invoke the shell and specify the path name to the script in the Command field, for example:

    /bin/sh /ul/myscripts/CheckLogs.sh

    In this example, the script must be installed in the above location on all target hosts for the job.

    Alternatively, in the Command field, you can specify a script that is in an accessible location over the network via NFS, for example:

    /bin/sh /net/myhostscripts/myScript.sh

  2. Invoke the shell in the Command field and the script itself in the OS Script field.

    For example:

    Command field: /bin/sh

    OS Script field: <script-commands-are-entered-here>

    Similarly, you could also specify a Perl script by specifying the location of the Perl executable in the Command field and the Perl script in the OS Script field, for example:

    Command field: /myPerlDirectory/bin/perl

    OS Script field: <perl-script-commands-are-entered-here>

Target properties can be used in both the Command and OS Script fields. Click Show Available Target Properties to view the properties you can use for the target. For example, if you want to access Oracle's Perl interpreter, you can specify:

Command field: %perlbin%/perl

OS Script field: <Perl-script-commands-are-entered-here>

Target properties are case-sensitive.

When your target is a Windows host, to use any Windows-related environment variables in the Command and OS Script fields, use %% to qualify them. For example, for the following command, the value of the Windows TEMP environment variable will be substituted for %%TEMP%% at runtime.:

Command field: %%TEMP%%/myProgram

You can specify a script that is up to 4 KB in size. There are no restrictions on scripting languages supported; all scripting languages are indirectly supported as long as you provide any required runtime interpreter in the Command field.

Specifying Targets for an OS Command Job

An OS Command job can be run against host, host group, database, database group, group, cluster, and cluster database targets. You select the targets to run the job against by clicking Add in the Targets section. The Add Targets page displays. Click Help on the Add Targets page for more information about selecting targets that the job will run against.

Once a target of a particular type is selected for the job, only targets of that same type can be added to the job.

If you specify a group as the target for this job, then the job will execute only against the hosts in the group.

Specifying Host Credentials for an OS Command Job

On the Credentials page, you specify the credentials that you want the Oracle Management Service to use when it runs the OS Command job against target hosts. The job can use either the job submitter's preferred credentials for hosts, or you can specify other credentials that will override the preferred credentials.

If you want to use the preferred credentials for hosts for your OS Command job, click Use Preferred Credentials and choose either Normal or Privileged in the Credential Type field. If you choose Normal, then your normal privileges will be used for the job; if you choose Privileged, then your privileged host credentials will be used for the job. Each time the job executes, it will pick up the current values of your preferred credentials.

To override the preferred credentials for all host targets, click Override Preferred Credentials and then enter the preferred credentials you want the job to use on all the hosts.

To view preferred credentials for hosts, click Show Preferred Credentials to display the Preferred Credentials page (right-click the link and open it in a new window to enable you to return easily to the Create Job page), then click the Set Credentials icon for hosts. Enterprise Manager displays the Host Preferred Credentials page. Click Help on the Host Preferred Credentials page for more information about host preferred credentials.

If the target for the OS Command job is a database or database group, then if you choose Use Preferred Credentials, the host credentials for the database target will be used. These are specified on the Database Preferred Credentials page and are different than the host credentials for the host on which the database resides.

To view preferred credentials for databases, click Show Preferred Credentials to display the Preferred Credentials page (right-click the link and open it in a new window to enable you to return easily to the Create Job page), then click the Set Credentials icon for databases. Enterprise Manager displays the Database Preferred Credentials page. Click Help on the Database Preferred Credentials page for more information about database preferred credentials.

 

Related Topics

About Job Executions and Runs

About Job Status

About Job Types

About Jobs

About Blackouts

About Steps

About the Jobs Purge Policy

Creating and Editing Jobs

Deleting Jobs

Filtering the List of Jobs

Single vs. Multiple Execution Runs

Viewing Job Results

Working with Multi-Task Jobs

Working with OS Command Jobs

Working with SQL Script Jobs

 

Enterprise Manager Information Roadmap