如何获取 rundeck 作业 PID 并对其进行回显

问题描述

如何获取 rundeck 作业 PID,然后回显它。

简单的回显 rundeck 作业 PID 任务

解决方法

Rundeck 将作业封装在 Java 线程中,跟踪 Rundeck 线程的一个好方法是使用 visualvm,无论如何,您可以通过相同的 UNIX/Linux 方式获取 Steps PID。最好的方法是按 scripts 步进行,例如:

ls &
echo $!

工作定义示例:

- defaultTab: nodes
  description: ''
  executionEnabled: true
  id: 0aeaa0f4-d090-4083-b0a5-2878c5f558d1
  loglevel: INFO
  name: HelloWorld
  nodeFilterEditable: false
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - fileExtension: .sh
      interpreterArgsQuoted: false
      script: |-
        ls &
        echo $!
      scriptInterpreter: /bin/bash
    keepgoing: false
    strategy: node-first
  uuid: 0aeaa0f4-d090-4083-b0a5-2878c5f558d1

Result

更新:相同的工作,但使用命令步骤:

- defaultTab: nodes
  description: ''
  executionEnabled: true
  id: 8c59758e-32f3-4166-92b0-50d818074368
  loglevel: INFO
  name: HelloWorld
  nodeFilterEditable: false
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - exec: ls & echo $!
    keepgoing: false
    strategy: node-first
  uuid: 8c59758e-32f3-4166-92b0-50d818074368

Result

,

ls & 回声 $!

当我尝试在本地命令选项上执行此命令时,结果是一个错误:'ls 无法访问 '&':没有这样的文件