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

     1  ---
     2  layout: docs
     3  page_title: 'Commands: alloc fs'
     4  description: |
     5    Introspect an allocation directory on a Nomad client
     6  ---
     7  
     8  # Command: alloc fs
     9  
    10  **Alias: `nomad fs`**
    11  
    12  The `alloc fs` command allows a user to navigate an [allocation working
    13  directory] on a Nomad client. The following functionalities are available -
    14  `cat`, `tail`, `ls` and `stat`.
    15  
    16  - `cat`: If the target path is a file, Nomad will `cat` the file.
    17  
    18  - `tail`: If the target path is a file and `-tail` flag is specified, Nomad will
    19    `tail` the file.
    20  
    21  - `ls`: If the target path is a directory, Nomad displays the name of a file and
    22    directories and their associated information.
    23  
    24  - `stat`: If the `-stat` flag is used, Nomad will display information about a
    25    file.
    26  
    27  ## Usage
    28  
    29  ```plaintext
    30  nomad alloc fs [options] <allocation> <path>
    31  ```
    32  
    33  This command accepts a single allocation ID (unless the `-job` flag is
    34  specified, in which case an allocation is chosen from the given job) and a
    35  path. The path is optional and relative to the root of the [allocation working
    36  directory].
    37  
    38  When ACLs are enabled, this command requires a token with the `read-fs`,
    39  `read-job`, and `list-jobs` capabilities for the allocation's namespace.
    40  
    41  ## General Options
    42  
    43  @include 'general_options.mdx'
    44  
    45  ## Fs Options
    46  
    47  - `-H`: Machine friendly output.
    48  
    49  - `-verbose`: Display verbose output.
    50  
    51  - `-job`: Use a random allocation from the specified job, preferring a running
    52    allocation.
    53  
    54  - `-stat`: Show stat information instead of displaying the file, or listing the
    55    directory.
    56  
    57  - `-f`: Causes the output to not stop when the end of the file is reached, but
    58    rather to wait for additional output.
    59  
    60  - `-tail`: Show the files contents with offsets relative to the end of the file.
    61    If no offset is given, -n is defaulted to 10.
    62  
    63  - `-n`: Sets the tail location in best-efforted number of lines relative to the
    64    end of the file.
    65  
    66  - `-c`: Sets the tail location in number of bytes relative to the end of the file.
    67  
    68  ## Examples
    69  
    70  ```shell-session
    71  $ nomad alloc fs eb17e557
    72  Mode        Size  Modified Time        Name
    73  drwxrwxr-x  4096  28 Jan 16 05:39 UTC  alloc/
    74  drwxrwxr-x  4096  28 Jan 16 05:39 UTC  redis/
    75  -rw-rw-r--  0     28 Jan 16 05:39 UTC  redis_exit_status
    76  
    77  
    78  $ nomad alloc fs eb17e557 redis/local
    79  Mode        Size  Modified Time        Name
    80  -rw-rw-rw-  0     28 Jan 16 05:39 UTC  redis.stderr
    81  -rw-rw-rw-  17    28 Jan 16 05:39 UTC  redis.stdout
    82  
    83  
    84  $ nomad alloc fs -stat eb17e557 redis/local/redis.stdout
    85  Mode        Size  Modified Time        Name
    86  -rw-rw-rw-  17    28 Jan 16 05:39 UTC  redis.stdout
    87  
    88  
    89  $ nomad alloc fs eb17e557 redis/local/redis.stdout
    90  foobar
    91  baz
    92  
    93  $ nomad alloc fs -tail -f -n 3 eb17e557 redis/local/redis.stdout
    94  foobar
    95  baz
    96  bam
    97  <blocking>
    98  ```
    99  
   100  ## Using Job ID instead of Allocation ID
   101  
   102  Setting the `-job` flag causes a random allocation of the specified job to be
   103  selected. Nomad will prefer to select a running allocation ID for the job, but
   104  if no running allocations for the job are found, Nomad will use a dead
   105  allocation.
   106  
   107  ```plaintext
   108  nomad alloc fs -job <job-id> <path>
   109  ```
   110  
   111  This can be useful for debugging a job that has multiple allocations, and it is
   112  not required to observe a specific allocation.
   113  
   114  [allocation working directory]: /docs/runtime/environment#task-directories 'Task Directories'