Updated on 2024-09-04 GMT+08:00

Running Shell Commands

This action aims to run shell scripts on a host in a specified environment. The following table shows the configuration.

Table 1 Parameters

Parameter

Description

Action Name

Name of an added deployment action. Max 128 characters. Do not start or end with a space. Use letters, digits, spaces, and these special characters: -_,;:./().

Environment

Select a host cluster as the deployment object.

Shell Commands

Bash scripts to run.

Control Options

  • Enable this action.
  • Continue the task even if this action fails.
  • Execute this action with the sudo permission.

Example: Using Shell Commands to View Service Logs

After application deployment is complete, you can run the shell commands to view the service startup or execution logs.

Preparations

  1. Ensure that you are an authorized user of a host. Only authorized users have the permissions required to view service startup or execution logs.
  2. Determine the full path of the service startup log.

    The following describes how to install the Tomcat service:

    Full path of the service startup log: /usr/local/tomcat/apache-tomcat-8.5.38/logs/catalina.out

Procedure

  1. Run the tail command to query the service startup or execution logs.
  2. Run the following command to query the last 20 lines of the log. The following figure shows the command output.

    tail -n 20 /usr/local/tomcat/apache-tomcat-8.5.38/logs/catalina.out

Do not run the cat command when running the shell command to view files. If the log file is too large, it may take some time to load data. Do not use the tail –f command.

If the shell command to be executed contains more than 10,240 characters, you are advised to Run Shell Script extension.

If you encounter any problem during deployment, see Solutions to Common Problems.