github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/commands/job/run.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: 'Commands: job run'
     4  sidebar_title: run
     5  description: |
     6    The job run command is used to run a new job.
     7  ---
     8  
     9  # Command: job run
    10  
    11  **Alias: `nomad run`**
    12  
    13  The `job run` command is used to submit new jobs to Nomad or to update existing
    14  jobs. Job files must conform to the [job specification] format.
    15  
    16  ## Usage
    17  
    18  ```plaintext
    19  nomad job run [options] <job file>
    20  ```
    21  
    22  The `job run` command requires a single argument, specifying the path to a file
    23  containing a valid [job specification]. This file will be read and the job will
    24  be submitted to Nomad for scheduling. If the supplied path is "-", the job file
    25  is read from STDIN. Otherwise it is read from the file at the supplied path or
    26  downloaded and read from URL specified. Nomad downloads the job file using
    27  [`go-getter`] and supports `go-getter` syntax.
    28  
    29  By default, on successful job submission the run command will enter an
    30  interactive monitor and display log information detailing the scheduling
    31  decisions and placement information for the provided job. The monitor will
    32  exit after scheduling has finished or failed.
    33  
    34  On successful job submission and scheduling, exit code 0 will be returned. If
    35  there are job placement issues encountered (unsatisfiable constraints, resource
    36  exhaustion, etc), then the exit code will be 2. Any other errors, including
    37  client connection issues or internal errors, are indicated by exit code 1.
    38  
    39  If the job has specified the region, the -region flag and `\$NOMAD_REGION`
    40  environment variable are overridden and the job's region is used.
    41  
    42  The run command will set the `consul_token` of the job based on the following
    43  precedence, going from highest to lowest: the `-consul-token` flag, the
    44  `$CONSUL_HTTP_TOKEN` environment variable and finally the value in the job file.
    45  
    46  The run command will set the `vault_token` of the job based on the following
    47  precedence, going from highest to lowest: the `-vault-token` flag, the
    48  `$VAULT_TOKEN` environment variable and finally the value in the job file.
    49  
    50  ## General Options
    51  
    52  @include 'general_options.mdx'
    53  
    54  ## Run Options
    55  
    56  - `-check-index`: If set, the job is only registered or
    57    updated if the passed job modify index matches the server side version.
    58    If a check-index value of zero is passed, the job is only registered if it does
    59    not yet exist. If a non-zero value is passed, it ensures that the job is being
    60    updated from a known state. The use of this flag is most common in conjunction
    61    with [`job plan` command].
    62  
    63  - `-detach`: Return immediately instead of monitoring. A new evaluation ID
    64    will be output, which can be used to examine the evaluation using the
    65    [eval status] command.
    66  
    67  - `-output`: Output the JSON that would be submitted to the HTTP API without
    68    submitting the job.
    69  
    70  - `-policy-override`: Sets the flag to force override any soft mandatory
    71    Sentinel policies.
    72  
    73  - `-consul-token`: If set, the passed Consul token is stored in the job before
    74    sending to the Nomad servers. This allows passing the Consul token without
    75    storing it in the job file. This overrides the token found in the \$CONSUL_HTTP_TOKEN
    76    environment variable and that found in the job.
    77  
    78  - `-vault-token`: If set, the passed Vault token is stored in the job before
    79    sending to the Nomad servers. This allows passing the Vault token without
    80    storing it in the job file. This overrides the token found in the \$VAULT_TOKEN
    81    environment variable and that found in the job.
    82  
    83  - `-verbose`: Show full information.
    84  
    85  ## Examples
    86  
    87  Schedule the job contained in the file `job1.nomad`, monitoring placement:
    88  
    89  ```shell-sessionnomad job run job1.nomad
    90  ==> Monitoring evaluation "52dee78a"
    91      Evaluation triggered by job "example"
    92      Evaluation within deployment: "62eb607c"
    93      Allocation "5e0b39f0" created: node "3e84d3d2", group "group1"
    94      Allocation "5e0b39f0" status changed: "pending" -> "running"
    95      Evaluation status changed: "pending" -> "complete"
    96  ==> Evaluation "52dee78a" finished with status "complete"
    97  ```
    98  
    99  <a id="check-index"></a> Update the job using `check-index`:
   100  
   101  ```shell-sessionnomad job run -check-index 5 example.nomad
   102  Enforcing job modify index 5: job exists with conflicting job modify index: 6
   103  Job not updated
   104  
   105  $ nomad job run -check-index 6 example.nomad
   106  ==> Monitoring evaluation "5ef16dff"
   107      Evaluation triggered by job "example"
   108      Evaluation within deployment: "62eb607c"
   109      Allocation "6ec7d16f" modified: node "6e1f9bf6", group "cache"
   110      Evaluation status changed: "pending" -> "complete"
   111  ==> Evaluation "5ef16dff" finished with status "complete"
   112  ```
   113  
   114  Schedule the job contained in `job1.nomad` and return immediately:
   115  
   116  ```shell-sessionnomad job run -detach job1.nomad
   117  4947e728
   118  ```
   119  
   120  Schedule a job which cannot be successfully placed. This results in a scheduling
   121  failure and the specifics of the placement are printed:
   122  
   123  ```shell-sessionnomad job run failing.nomad
   124  ==> Monitoring evaluation "2ae0e6a5"
   125      Evaluation triggered by job "example"
   126      Evaluation status changed: "pending" -> "complete"
   127  ==> Evaluation "2ae0e6a5" finished with status "complete" but failed to place all allocations:
   128      Task Group "cache" (failed to place 1 allocation):
   129        * Class "foo" filtered 1 nodes
   130        * Constraint "${attr.kernel.name} = linux" filtered 1 nodes
   131      Evaluation "67493a64" waiting for additional capacity to place remainder
   132  ```
   133  
   134  [`go-getter`]: https://github.com/hashicorp/go-getter
   135  [`job plan` command]: /docs/commands/job/plan
   136  [eval status]: /docs/commands/eval-status
   137  [job specification]: /docs/job-specification