Execute a Command or Script on Grid Hosts (hostExec)

The hostExec command runs a command (such as a system command or TimesTen command) or a script on hosts in the grid, as specified.

ttGridAdmin hostExec [-only hostname]
                     [-exclude hostname]
                     [-parallel n]
                      command | -script filepath

Options

The hostExec command has the options:

Option Description

-only hostname

The command or script is run only on the specified hosts. Specify just one host with -only, but you can use -only multiple times on the command line.

Use host names as defined in the model.

Without -only or -exclude, the command or script is run on all hosts in the model.

-exclude hostname

The command or script is performed on all hosts in the grid except for the specified hosts. Specify just one host with -exclude, but you can use -exclude multiple times on the command line.

Use host names as defined in the model.

Without -only or -exclude, the command or script is performed on all hosts in the model.

-parallel n

Specifies that the command or script runs on no more than n hosts simultaneously. The default is 10. A value of 1 results in serial execution.

command | -script filepath

command specifies a command to run.

Or:

-script filepath specifies the path and name of a shell script to run. The script must be on the local system, then is copied to each host.

Examples

This example first shows the existing hosts in the grid, then uses hostExec to run the df / command (to show disk space) on each host, excluding mysys3host and mysys4host. So the command is performed on mysys1host and mysys2host.

% ttGridAdmin hostList
Name        IntAddress             ExtAddress             DSG Comment
----------- ---------------------- ---------------------- --- -------
mysys1host  intmysys1.example.com  extmysys1.example.com    1
mysys2host  intmysys2.example.com  extmysys2.example.com    2
mysys3host  intmysys3.example.com  extmysys3.example.com    1
mysys4host  intmysys4.example.com  extmysys4.example.com    2

% ttGridAdmin hostExec -exclude mysys3host -exclude mysys4host df /
Commands executed on:
  mysys1host rc 0
  mysys2host rc 0
Return code from mysys1host: 0
Output from mysys1host:
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda2           173483816  28416336 136254988  18% /
Return code from mysys2host: 0
Output from mysys2host:
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda2           117144964  35319512  75874836  32% /

Notes

  • The command or script is run on each host as the instance administrator through passwordless SSH.

  • No environment variables are set on the hosts, other than those set by SSH by default.

  • The command returns 2000 if execution did not complete prior to the timeout.

  • During execution, stdout and stderr output is displayed as part of the stdout and stderr output from the hostExec command. Because output is buffered, the output from different commands is not intermingled.