简体   繁体   English

Linux在PUTTY / SSH中加载时停止命令

[英]Linux stop a command while its loading in PUTTY/SSH

Let me start of by saying i just started learning linux. 让我先说我刚开始学习linux。

I have a command that keeps processing/loading until i press CTRL+C to cancel/stop the command and remain in session. 我有一个命令,一直处理/加载,直到我按CTRL + C取消/停止命令并保持在会话中。

What i want is to send that command, wait x amount of seconds and then close it programmatically in a single command (cause i can't enter new commands when its loading). 我想要的是发送该命令,等待x秒,然后在一个命令中以编程方式关闭它(因为我加载时无法输入新命令)。 Sorry if it sounds stupid, but that would solve my problem. 对不起,如果它听起来很愚蠢,但这可以解决我的问题。

Would really appreciate if someone could've helped me out here, couldn't find anything on google that was working (mostly exiting the session while the command remains loading). 真的很感激,如果有人可以帮助我在这里,在谷歌找不到任何工作(大多数退出会话,而命令仍在加载)。

Use sleep command for terminate the process. 使用sleep命令终止进程。 example: echo helloword & sleep 1 --> time indicates in seconds.After executing the echo command it will wait for one second and then it terminate the echo process 例如:echo helloword&sleep 1 - > time表示以秒为单位。执行echo命令后,它将等待一秒,然后终止回显进程

use nohup. 使用nohup。 example: 例:

nohup ./foobar.sh & < /dev/null > ./log 2>&1 
exit

In foobar.sh you can have the following content foobar.sh您可以拥有以下内容

command you wish to execute

sleep <no of seconds>

or you can use "screen", you need to install "screen" in you host, then 或者您可以使用“屏幕”,然后您需要在主机中安装“屏幕”

> screen {your-cmd}

and press ctrl+A followed ctrl+D detach current (but your cmd still running) session . 然后按ctrl + A,然后按ctrl + D分离当前(但你的cmd仍在运行)会话。

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

相关问题 将Linux连接到solaris时,ssh命令不起作用 - ssh command is not working while connecting linux to solaris 关闭PuTTY SSH会话后,如何运行仍在运行的Linux命令? - How can I run a Linux command that still runs after I close my PuTTY SSH session? 如何使用ssh或putty在linux上安装ffmpeg - How to install ffmpeg on linux using ssh or putty 使用SSH腻子在Red Hat Linux上安装MySQL - MySQL installation on Red Hat Linux using SSH putty 如何使用纯命令行命令复制腻子SSH隧道设置? - how to replicate putty ssh tunnel settings with pure command line commands? 当我在 Linux 机器上运行时显示其执行日志的命令,但是当我通过 ssh 触发相同的命令时,它不显示日志 - command showing its execution log when I run in Linux machine but when I trigger same command over ssh its not displaying log 隐藏c ++的输出同时在c ++中执行Linux shell命令 - Execute Linux shell command in c++ while hiding its output python ssh linux ssh 命令的脚本 - python ssh script for linux ssh command 我在使用命令行“ Putty”在Linux上工作时遇到此问题 - i was working on Linux using Command Line 'Putty' and i encountered this issue 使用 PuTTY 从 Windows 自动运行 Linux 上的命令 - Automating running command on Linux from Windows using PuTTY
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM