简体   繁体   English

在特定的 python 文件上自动创建 tmux 会话。 (重击?)

[英]Automate tmux session creation on specific python file. (bash ?)

I am new to all this server side stuff, and I have a server on which I need to start up multiple tmux sessions with the same python script multiple times.我对所有这些服务器端的东西都是新手,并且我有一个服务器,我需要在该服务器上多次使用相同的 python 脚本启动多个 tmux 会话。

How can I automate this process,( usign bash etc) This is what I do currently:我怎样才能自动化这个过程,(使用 bash 等)这是我目前所做的:

tmux / cd python /pyhon3 xshares.py / ctrl-b / d / tmux ...

Repeatedly, which takes a lot of time, thanks for your help.重复,这需要很多时间,感谢您的帮助。

I'm creator of 2 open source, python-based tmux(1) tools: libtmux and tmuxp .我是 2 个基于 python 的开源tmux(1)工具的创建者: libtmuxtmuxp

tmux session managers tmux 会话管理器

If I had to guess, by "automate" you are looking for a "tmux session manager".如果我不得不猜测,通过“自动化”,您正在寻找“tmux 会话管理器”。 Some of those include (non-exhaustively):其中一些包括(非详尽):

The gist of these tools is there's a declarative YAML configuration encapsulating a tmux session, and its windows and panes.这些工具的要点是有一个封装了 tmux 会话及其窗口和窗格的声明性YAML配置。

To get a better idea what this looks like, assume mysession.yaml :为了更好地了解这是什么样子,假设mysession.yaml

session_name: my session
windows:
  - window_name: another window
    panes:
    - shell_command:
      - python3 ./myscript.py
    - shell_command: python3 ./myscript2.py
  - window_name: another window
    panes:
    - shell_command:
      - pane
    - pane

You could then launch it via command (assuming you have tmuxp installed via pip install --user tmuxp ):然后您可以通过命令启动它(假设您通过pip install --user tmuxp ):

tmuxp load ./mysession.yaml

This will create and automatically launch you into the tmux session declared in the YAML file.这将创建并自动启动您进入 YAML 文件中声明的 tmux 会话。 Here are some examples for inspiration.以下是一些启发灵感的例子

Scripting tmux脚本 tmux

On the outside chance I misunderstood - eg you want to pilot tmux programmatically, you could do this through shell commands to tmux itself or libtmux.在外部机会我误解了 - 例如,您想以编程方式试用 tmux,您可以通过 shell 命令对tmux本身或 libtmux 执行此操作。 It could be better to ask a question pivoted toward manual , scripted control of tmux.最好问一个以手动脚本控制 tmux 为中心的问题。 I can help with that, too.我也可以帮忙。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM