github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/commands/job/allocs.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: 'Commands: job allocs'
     4  description: |
     5    The allocs command is used to list allocations for a job.
     6  ---
     7  
     8  # Command: job allocs
     9  
    10  The `job allocs` command is used to display the allocations for a
    11  particular job.
    12  
    13  ## Usage
    14  
    15  ```plaintext
    16  nomad job allocs [options] <job>
    17  ```
    18  
    19  The `job allocs` command requires a single argument, the job ID or an ID
    20  prefix of a job to display the list of allocations for.
    21  
    22  When ACLs are enabled, this command requires a token with the `read-job` and
    23  `list-jobs` capabilities for the job's namespace.
    24  
    25  ## General Options
    26  
    27  @include 'general_options.mdx'
    28  
    29  ## Allocs Options
    30  
    31  - `-all`: Display all allocations matching the job ID, even those from an
    32    older instance of the job.
    33  
    34  - `-json`: Output the allocations in JSON format.
    35  
    36  - `-t`: Format and display the allocations using a Go template.
    37  
    38  - `-verbose`: Show full information.
    39  
    40  ## Examples
    41  
    42  List the allocations for a particular job:
    43  
    44  ```shell-session
    45  $ nomad job allocs example
    46  ID        Node ID   Task Group  Version  Desired  Status   Created   Modified
    47  c2b4606d  35085106  cache       2        run      running  21s ago   10s ago
    48  c413424b  35085106  cache       2        run      pending  1m8s ago  11s ago
    49  ```
    50  
    51  Verbose listing of allocations for a particular job:
    52  
    53  ```shell-session
    54  $ nomad job allocs -verbose example
    55  ID                                    Eval ID                               Node ID                               Node Name  Task Group  Version  Desired  Status   Created                    Modified
    56  c2b4606d-1b02-0d8d-5fdd-031167cd4c91  5e2badb6-b7cf-5177-8281-8fe14f7193d2  35085106-9480-b465-a348-deb745024394  ubuntu     cache       2        run      running  2021-09-23T14:45:09-04:00  2021-09-23T14:45:19-04:00
    57  c413424b-d80e-9bc6-ea92-a02b336eaaf5  5e2badb6-b7cf-5177-8281-8fe14f7193d2  35085106-9480-b465-a348-deb745024394  ubuntu     cache       2        run      pending  2021-09-23T14:44:22-04:00  2021-09-23T14:45:19-04:00
    58  ```
    59  
    60  Format job allocations using a Go template:
    61  ```shell-session
    62  $ nomad job allocs -t '{{ range . }}{{ println .ID }}{{ end }}' example
    63  c2b4606d-1b02-0d8d-5fdd-031167cd4c91
    64  c413424b-d80e-9bc6-ea92-a02b336eaaf5
    65  ```
    66  
    67  Use a Go template to filter only allocations which are running
    68  ```shell-session
    69  $ nomad job allocs -t '{{ range . }}{{ if eq .ClientStatus "running" }}{{ println .ID }}{{ end }}{{ end }}' example
    70  c2b4606d-1b02-0d8d-5fdd-031167cd4c91
    71  ```
    72  
    73  Refer to the [Format Nomad Command Output With Templates][format_tutorial]
    74  tutorial for more examples of using Go templates to format Nomad CLI output.
    75  
    76  [format_tutorial]: https://learn.hashicorp.com/tutorials/nomad/format-output-with-templates