Important

   

Starting version 8.9.03, BMC Server Automation is renamed to TrueSight Server Automation. This space contains information about BMC Server Automation 8.9.02 and previous versions. For TrueSight Server Automation 8.9.03 and later releases, see TrueSight Server Automation 8.9.

Defining precommands and postcommands

The Pre/Post Commands dialog box lets you execute commands on a target directory before and after a package is deployed to a server. It also lets you execute commands on a target directory before a deployment is undone and after it is undone.

A precommand or postcommand can consist of a number of commands that can be executed by the native operating system of a remote host. After you define precommands or postcommands, they are saved to the file server as script files. When a job runs, it uses the nexec -e command to execute the precommand or postcommand. When you execute a precommand, the target directory is first created (if it does not already exist) and then the precommand is executed in the target directory. Postcommands are executed in the target directory.

You can create precommands and postcommands by entering commands in the text box or importing text from a file on any managed server.

To define pre/post commands

  1. Click Pre/Post Commands. The Pre/Post Commands dialog box opens.
  2. To define precommands and postcommands, click one of the following:
    • Deploy tab — Define precommands and postcommands for a package deployment.
    • Undo tab — Define precommands and postcommands for undoing a package deployment.
  3. For Deployment path, enter the path where precommands and postcommands, in script form, are written during deployment so they can be run on an agent.
    By default, commands are written to /tmp.
    The path can include a parameter. Enter the parameter manually or click Select Property
    , which appears when you click in the Value column. (For more information about using this tool, see Inserting a parameter.)
  4. Take any of the following actions:
    • For Pre-command, enter the command that you want to execute before the deployment begins. To import the text of the command, click Browse and navigate to the file containing that text.
      If a precommand must execute successfully for the deployment to complete, check Must have 0 exit status.
    • For Post-command, enter the command that you want to execute after the deployment ends. Postcommands are executed in the target directory. To import the text of the command, click Browse and navigate to the file containing that text.
      If a postcommand must execute successfully for the deployment to complete, check Post command should have 0 exit status.
      If necessary, click Zoom to open a dialog box that gives you a larger text box to edit pre- and postcommands. When you finish editing the command, click OK.
  5. Click OK to close the Pre/Post Commands dialog box.

Note

The pre and post commands are not reboot-aware, so the Job will not know if the pre or post commands initiated a reboot and will not wait for a reboot to complete. So, for example, if the pre-command contains a reboot command, the Job might fail, as the server would be rebooting when the main section of the job starts to run.

Was this page helpful? Yes No Submitting... Thank you

Comments