-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
layout: docs | ||
page_title: 'Commands: job allocs' | ||
description: | | ||
The allocs command is used to list allocations for a job. | ||
--- | ||
|
||
# Command: job allocs | ||
|
||
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` and | ||
`list-jobs` capabilities for the job's namespace. | ||
|
||
## General Options | ||
|
||
@include 'general_options.mdx' | ||
|
||
## Deployment Options | ||
|
||
- `-json` : Output the allocations in JSON format. | ||
|
||
- `-t` : Format and display the allocations using a Go template. | ||
|
||
- `-verbose`: Show full information. | ||
|
||
- `-all`: Display all allocations matching the job ID, even those from an | ||
older instance of the job. | ||
|
||
## 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](https://learn.hashicorp.com/tutorials/nomad/format-output-with-templates)] tutorial for more examples of using Go templates to format Nomad CLI output. |