如何 运行 bash 命令不停止我的终端

How to run bash command without stalling my terminal

我想要 运行 一个使我的终端停止运行的应用程序,但随后我需要再次使用该终端并且不能让它停止运行,是否有某种前缀我可以应用于将允许它异步 运行 吗?示例:

async mousepad

添加&使程序在后台运行运行。

来自bash manual:

If a command is terminated by the control operator &, the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0. These are referred to as asynchronous commands.

您需要 运行 它在后台运行。还没有用那个鼠标垫命令试过,但希望这能奏效。

nohup "COMMAND" &

nohup async mousepad &

https://linuxize.com/post/how-to-run-linux-commands-in-background/

您需要 运行 它在后台运行。推荐screen工具

屏幕支持session recoverymulti windowsession sharing

  • 会话恢复

As long as the screen itself is not terminated, the session running inside it can be resumed. This is especially useful for remote login users - even if the network connection is interrupted, the user will not lose control of the opened command line session. Just log in to the host again and execute screen - r to resume the operation of the session. Similarly, when you leave temporarily, you can also execute the detach command detach to suspend the screen (switch to the background) while ensuring the normal operation of the program inside. This is very similar to VNC in the graphical interface.

  • 多个window

In the screen environment, all sessions run independently and have their own number, input, output and window cache. Users can switch between different windows through shortcut keys, and can freely redirect the input and output of each window. Screen realizes basic text operations, such as copy and paste; It also provides a function similar to scroll bar, which can view the history of window status. Windows can also be partitioned and named, and the activity of background windows can be monitored.

  • 会话共享

Screen allows one or more users to log in to a session multiple times from different terminals and share all the features of the session (for example, you can see exactly the same output). It also provides the mechanism of window access permission, which can protect the window with password.