[英]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.