退出putty是否会关闭正在运行的命令

发布于 2024-11-07 13:49:27 字数 127 浏览 0 评论 0原文

我使用 rsync 在服务器之间使用 putty 复制 15GB 文件。 我想知道,如果我关闭 putty 终端,是否也会终止 rync,因为文件未正确复制。

我尝试过,当我进行备份时,即使我关闭腻子,脚本也会继续在后台运行

I was using rsync to copy 15GB files between servers using putty.
I want to know that if i close putty terminal does that also termiates rync or not because file is not copied properly.

I have tried that when i am doing backups then even if i close putty then scrip continue to run in background

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

顾忌 2024-11-14 13:49:27

假设您的目标是让 rsync 命令继续运行,最简单的事情就是孤立该作业。有两种方法可以做到这一点:

(rsync foo bar &)

上面的方法将在开始时创建与终端分离的作业,因此关闭终端不会停止它。

rsync foo bar & # or without &, then Ctrl-Z to stop, then "bg" to background
disown

以上将否认正在运行的作业,因此您可以关闭终端而不停止它。

最后,您可以使用 screen(1) 程序或类似程序来保持终端会话处于活动状态且完好无损(并且能够恢复),即使您结束 Putty 会话也是如此。

Assuming your goal is to have the rsync command continue to run, the simplest thing is to orphan the job. There are two ways to do this:

(rsync foo bar &)

The above will create the job detached from your terminal in the beginning, so closing the terminal will not stop it.

rsync foo bar & # or without &, then Ctrl-Z to stop, then "bg" to background
disown

The above will disown a running job, so you can close the terminal without stopping it.

Finally, you could use the program screen(1) or similar to keep a terminal session alive and intact (and able to be resumed) even when you end your Putty session.

誰ツ都不明白 2024-11-14 13:49:27

我建议在 GNU Screen 会话。

然后,您可以断开会话连接(如果愿意,可以通过关闭 PuTTY)并稍后重新连接以查看工作进展情况。


稍后更新...

这些天我使用并推荐

I'd advocate performing long operations such as rsyncing 15GB across a network (or more pertinent to StackOverflow and programming, performing a large build on a remote host) within a GNU Screen session.

Then you can disconnect from the session (by closing PuTTY, if you like) and reconnect later to see how your job is progressing.


Update some time later...

These days I use and recommend over .

闻呓 2024-11-14 13:49:27

一般来说,如果控制台关闭,大多数命令都会退出。如果您希望它们继续运行,请查看 NOHUP 命令(Nohup 是“无挂断进程”,是调制解调器和“挂断”电话时代的遗留问题)

Generally most command will quit if the console is closed. If you want them to keep running look at the NOHUP command (Nohup is No Hang Up Process, a hang over from the days of modems and 'hanging up' the phone)

挽手叙旧 2024-11-14 13:49:27

假设您正在某个客户端上运行 rsync,则进程的正常行为是在失去其控制 tty 时终止(当您关闭 putty 时就是这种情况)。然而,您可以使用 nohup (NOHUP(1)) 运行作业,我猜这就是您的备份脚本正在做的事情(如果不涉及其他“技巧”)。然后,rsync 命令的输出将被附加到当前目录或主目录中的 nohup.out 文件中,具体取决于您对运行 nohup 进程的计算机的权限。

Assuming you are running a rsync on some client the normal behaviour of a process is to terminate if it was loosing its controlling tty which is the case when you close putty. You may however run jobs with nohup (NOHUP(1)), and i guess that is what your backup scripts are doing (if no other "tricks" were involved). The output of your rsync commadn will then be appended to a file nohup.out in the current or your home directory depending on your permissions on the machine the nohup process is running on.

零時差 2024-11-14 13:49:27

原因:

当您在后台执行 Unix 作业(使用 &、bg 命令)并从会话注销时,您的进程将被终止(挂起)。

两种解决办法:

1./nohup,代表不挂机,可以如下执行。

nohup 语法:

# nohup command-with-options &

2./

(command-with-options &)

Reason:

When you execute a Unix job in the background ( using &, bg command), and logout from the session, your process will get killed(Hang Up).

Two solutions:

1./ Nohup, which stands for no hang up, which can be executed as shown below.

nohup syntax:

# nohup command-with-options &

2./

(command-with-options &)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文