在后台运行 rsync

发布于 2024-11-10 12:00:59 字数 153 浏览 3 评论 0原文

我用它在后台运行 rsync

rsync -avh /home/abc/abac /backups/ddd &

当我这样做时,我看到一行说 1 个进程已停止。

现在这是否意味着我的进程仍在运行或已停止

I use this to run rsync in background

rsync -avh /home/abc/abac /backups/ddd &

When i do that i see line saying 1 process stopped.

Now does that mean my process is still running ot it is stopped

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

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

发布评论

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

评论(7

因为看清所以看轻 2024-11-17 12:00:59

当您按“ctrl + z”时,进程就会停止并转到后台。

[1]+ 已停止 rsync -ar --partial /home/webup/ /mnt/backup/

现在按“bg”,将在后台启动您停止的上一个进程。

[1]+ rsync -ar --partial /home/webup/ /mnt/backup/ &

按“jobs”查看进程正在运行

[1]+ 运行 rsync -ar --partial /home/webup/ /mnt/backup/ &

如果你想进入前台按“fg 1”1是进程号

When you press "ctrl + z" then the process stopped and go to background.

[1]+ Stopped rsync -ar --partial /home/webup/ /mnt/backup/

Now press "bg" and will start in background the previous process you stopped.

[1]+ rsync -ar --partial /home/webup/ /mnt/backup/ &

Press "jobs" to see the process is running

[1]+ Running rsync -ar --partial /home/webup/ /mnt/backup/ &

If you want to to go in foreground press "fg 1" 1 is the process number

放飞的风筝 2024-11-17 12:00:59

保持 rsync 在后台运行的解决方案

nohup rsync -a host.origin:/path/data destiny.host:/path/ &

Nohup 允许运行进程/命令或 shell 脚本以继续在后台工作,即使您关闭终端会话也是如此。

在我们的示例中,我们还添加了“&”最后,这有助于将进程发送到后台。

输出示例:

 nohup rsync -avp [email protected]:/root/backup/uploads/ . &

 [1] 33376
 nohup: ignoring input and appending output to 'nohup.out'

就是这样,现在你的 rsync 进程将在后台运行,无论发生什么它都会在那里,除非你从命令行杀死该进程,但如果你关闭 Linux 终端,或者注销,它不会被中断从服务器。

RSync 状态

cat nohup.out

The solution to keep rsync running in background

nohup rsync -a host.origin:/path/data destiny.host:/path/ &

Nohup allows to run a process/command or shell script to continue working in the background even if you close the terminal session.

In our example, we also added ‘&’ at the end, that helps to send the process to background.

Output example:

 nohup rsync -avp [email protected]:/root/backup/uploads/ . &

 [1] 33376
 nohup: ignoring input and appending output to 'nohup.out'

That’s all, now your rsync process will run in the background, no matter what happens it will be there unless you kill the process from command line, but it will not be interrupted if you close your linux terminal, or if you logout from the server.

RSync Status

cat nohup.out
梦里的微风 2024-11-17 12:00:59

它可能正在尝试从终端读取(也许是要求您输入密码)。当后台进程尝试从终端读取数据时,它会被停止。

您可以通过从 /dev/null 重定向 stdin 来消除错误:

rsync -avh /home/abc/abac /backups/ddd < /dev/null &

...但是它可能会失败,因为它将无法读取它试图读取的任何内容。

It is probably trying to read from the terminal (to ask you for a password, perhaps). When a background process tries to read from the terminal, it gets stopped.

You can make the error go away by redirecting stdin from /dev/null:

rsync -avh /home/abc/abac /backups/ddd < /dev/null &

...but then it will probably fail because it will not be able to read whatever it was trying to read.

一曲爱恨情仇 2024-11-17 12:00:59

不,这意味着它已经停止了。

您可以使用jobs进行检查。

输出示例:

jobs
[1]+  Stopped                 yes

然后您可以使用 fg 重新激活,例如:

fg 1

No, it means it has been stopped.

You can check it with jobs.

Example output:

jobs
[1]+  Stopped                 yes

Then you can reactivate with fg, example:

fg 1
一袭白衣梦中忆 2024-11-17 12:00:59

这是安全的,您可以监视 nohup.out 以查看进度。

nohup rsync -avrt --exclude 'i386*' --exclude 'debug' rsync://mirrors.kernel.org/centos/6/os . & 

This is safe, you can monitor nohup.out to see the progress.

nohup rsync -avrt --exclude 'i386*' --exclude 'debug' rsync://mirrors.kernel.org/centos/6/os . & 
眼藏柔 2024-11-17 12:00:59

文件传输:

nohup scp oracle@<your_ip>:/backup_location/backup/file.txt . > nohup.out 2>&1 &

然后按 ctrl-z

$ bg

使命令生效

File Transfer:

nohup scp oracle@<your_ip>:/backup_location/backup/file.txt . > nohup.out 2>&1 &

then hit ctrl-z

$ bg

To bring the command alive

时光是把杀猪刀 2024-11-17 12:00:59

如果一切正常,您的调用应该会返回新进度的 PID,并在一段时间后返回“完成”消息。

所以是的,你的输出看起来你的进程没有运行。

检查 ps 以查看 rsync 是否正在运行。

If everything works, your call should return you the PID of the new progress and some time later a "Done" message.

So yeah, your output looks like your process is not running.

Check ps to see if rsync is running.

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