Files
nomad/website/content/docs/commands/job/allocs.mdx
Aimee Ukasick dae496e427 Docs: SEO front matter description for search: commands section (#25175)
* Enhance front matter description for search

* acl section

* alloc section

* config section

* deployment section

* eval section

* job section

* license section

* namespace section

* node section

* node pool section

* operator section

* plugin section

* quota section

* recommendation section

* scaling section

* sentinel section

* server section

* service section

* setup section

* system section

* tls section

* var section

* volume section

* change reference to command reference

* Apply suggestions from code review

Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com>

---------

Co-authored-by: Jeff Boruszak <104028618+boruszak@users.noreply.github.com>
2025-03-19 12:02:02 -05:00

78 lines
2.7 KiB
Plaintext

---
layout: docs
page_title: 'nomad job allocs command reference'
description: |
The `nomad job allocs` command lists allocations for a job.
---
# `nomad job allocs` command reference
The `job allocs` command is used to display the allocations for a
particular job.
## Usage
```plaintext
nomad job allocs [options] <job>
```
The `job allocs` command requires a single argument, the job ID or an ID
prefix of a job to display the list of allocations for.
When ACLs are enabled, this command requires a token with the `read-job`
capability for the job's namespace. The `list-jobs` capability is required to
run the command with a job prefix instead of the exact job ID.
## General options
@include 'general_options.mdx'
## Allocs options
- `-all`: Display all allocations matching the job ID, even those from an
older instance of the job.
- `-json`: Output the allocations in JSON format.
- `-t`: Format and display the allocations using a Go template.
- `-verbose`: Show full information.
## Examples
List the allocations for a particular job:
```shell-session
$ nomad job allocs example
ID Node ID Task Group Version Desired Status Created Modified
c2b4606d 35085106 cache 2 run running 21s ago 10s ago
c413424b 35085106 cache 2 run pending 1m8s ago 11s ago
```
Verbose listing of allocations for a particular job:
```shell-session
$ nomad job allocs -verbose example
ID Eval ID Node ID Node Name Task Group Version Desired Status Created Modified
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
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
```
Format job allocations using a Go template:
```shell-session
$ nomad job allocs -t '{{ range . }}{{ println .ID }}{{ end }}' example
c2b4606d-1b02-0d8d-5fdd-031167cd4c91
c413424b-d80e-9bc6-ea92-a02b336eaaf5
```
Use a Go template to filter only allocations which are running
```shell-session
$ nomad job allocs -t '{{ range . }}{{ if eq .ClientStatus "running" }}{{ println .ID }}{{ end }}{{ end }}' example
c2b4606d-1b02-0d8d-5fdd-031167cd4c91
```
Refer to the [Format Nomad Command Output With Templates][format_tutorial]
tutorial for more examples of using Go templates to format Nomad CLI output.
[format_tutorial]: /nomad/tutorials/templates/format-output-with-templates