在后台运行 rsync
我用它在后台运行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
当您按“ctrl + z”时,进程就会停止并转到后台。
现在按“bg”,将在后台启动您停止的上一个进程。
按“jobs”查看进程正在运行
如果你想进入前台按“fg 1”1是进程号
When you press "ctrl + z" then the process stopped and go to background.
Now press "bg" and will start in background the previous process you stopped.
Press "jobs" to see the process is running
If you want to to go in foreground press "fg 1" 1 is the process number
保持 rsync 在后台运行的解决方案
Nohup 允许运行进程/命令或 shell 脚本以继续在后台工作,即使您关闭终端会话也是如此。
在我们的示例中,我们还添加了“&”最后,这有助于将进程发送到后台。
输出示例:
就是这样,现在你的 rsync 进程将在后台运行,无论发生什么它都会在那里,除非你从命令行杀死该进程,但如果你关闭 Linux 终端,或者注销,它不会被中断从服务器。
RSync 状态
The solution to keep rsync running in background
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:
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
它可能正在尝试从终端读取(也许是要求您输入密码)。当后台进程尝试从终端读取数据时,它会被停止。
您可以通过从 /dev/null 重定向 stdin 来消除错误:
...但是它可能会失败,因为它将无法读取它试图读取的任何内容。
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:
...but then it will probably fail because it will not be able to read whatever it was trying to read.
不,这意味着它已经停止了。
您可以使用
jobs
进行检查。输出示例:
然后您可以使用
fg
重新激活,例如:No, it means it has been stopped.
You can check it with
jobs
.Example output:
Then you can reactivate with
fg
, example:这是安全的,您可以监视 nohup.out 以查看进度。
This is safe, you can monitor nohup.out to see the progress.
文件传输:
然后按 ctrl-z
使命令生效
File Transfer:
then hit ctrl-z
To bring the command alive
如果一切正常,您的调用应该会返回新进度的 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.