如何让 Terminator 在远程机器上打开尾随(less +F)日志文件的选项卡

如何让 Terminator 在远程机器上打开尾随(less +F)日志文件的选项卡

我想开发一个终结器布局,打开 4 个选项卡,其中 3 个选项卡以跟踪模式 ( less +F <logfile>) 显示远程计算机上的日志文件,最后一个选项卡监视文件夹的内容指挥值班

为了更好地解释,这是我作为用户手动执行的操作来实现我想要的效果:

首先,我会手动将 Terminator 窗口拆分为 4 个选项卡,显示为 2x2:1 个垂直拆分,1 个水平拆分

 1  |  2
----------
 3  |  4

然后在每个选项卡中运行以下命令:

标签 1

ssh user_P@remote_machine_ip
sudo -i -u user_O
less +F /path/to/log1/log1.log

标签 2

ssh user_P@remote_machine_ip
sudo -i -u user_O
less +F /path/to/log2/log2.log

标签 3

ssh user_P@remote_machine_ip
sudo -i -u user_O
sudo less +F /path/to/log3/log3.log 

标签 4

ssh user_P@remote_machine_ip
sudo -i -u user_O
watch -n 1 ls /home/user_O/my_folder/

答案1

1 - 创建并保存所需的选项卡配置布局

此主题很好地解释了如何去做。

首先通过运行打开终结器配置文件

xdg-open /home/your_local_user/.config/terminator/config


2 - 编写要为每个选项卡运行的命令

在本节下,[[your-custom-layout-name]]您必须command = ...在每个文本片段下添加一个键,例如

 [[[terminal<number>]]]
       type = Terminal

你的标签的每个键的内容command应该是:

标签 1

command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O less +F /path/to/log1/log1.log

标签 2

command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O sudo less +F /path/to/log2/log2.log

标签 3

command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O less +F /path/to/log1/log1.log

标签 4

command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O watch -n 1 ls /home/user_O/my_folder/

最后你的布局看起来应该是这样的:

[global_config]
  enabled_plugins = LaunchpadBugURLHandler, LaunchpadCodeURLHandler, APTURLHandler, TerminalShot, SelectAll
  case_sensitive = False
[keybindings]
[profiles]
  [[default]]
    cursor_color = "#aaaaaa"
[layouts]
  [[default]]
    [[[window0]]]
      type = Window
      parent = ""
    [[[child1]]]
      type = Terminal
      parent = window0
      profile = default
  [[your-custom-layout-name]]
    [[[child0]]]
      type = Window
      parent = ""
      order = 0
      position = 0:0
      maximised = True
      fullscreen = False
      size = 1920, 773
      title = user_O@remote_machine_alias
      last_active_term = 99c695d1-9a3e-43bb-a424-55ed77e9e4e8
      last_active_window = False
    [[[child1]]]
      type = HPaned
      parent = child0
      order = 0
      position = 958
      ratio = 0.5002610966057441
    [[[child2]]]
      type = VPaned
      parent = child1
      order = 0
      position = 385
      ratio = 0.5013020833333334
    [[[terminal3]]]
      type = Terminal
      title = tab 1
      command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O less +F /path/to/log1/log1.log
      parent = child2
      order = 0
      profile = default
      uuid = 6cebd0a2-f543-41e9-8cb4-dcfad9feb41c
    [[[terminal4]]]
      type = Terminal
      title = tab 3
      command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O less +F /path/to/log3/log3.log
      parent = child2
      order = 1
      profile = default
      uuid = d328e8b6-8822-4880-b9d6-97ca87cae185
    [[[child5]]]
      type = VPaned
      parent = child1
      order = 1
      position = 385
      ratio = 0.5013020833333334
    [[[terminal6]]]
      type = Terminal
      title = tab 2
      command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O sudo less +F /path/to/log2/log2.log
      parent = child5
      order = 0
      profile = default
      uuid = 99c695d1-9a3e-43bb-a424-55ed77e9e4e8
    [[[terminal7]]]
      type = Terminal
      title = tab 4
      command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O watch -n 1 ls /home/user_O/my_folder/
      parent = child5
      order = 1
      profile = default
      uuid = 777a548f-868b-4a80-81d7-5cf973de5cad
[plugins]

最后,从你的终端打开带有自定义布局的终结器

terminator -l your-custom-layout-name

警告

在从终结器 UI 关闭 less/watch 中的每个选项卡之前,必须使用CTRL+停止,否则 less/watch 进程将在后台模式下继续,从而耗尽您的 CPU。C

相关内容