大网数据广告活动
服务器运维问答

Run remote script & monitoring his activity without keeping connection

· 52CE 我爱测

I work on Linux Mint myself, have remote Ubuntu VPS server with root ssh access. I have script on server which makes long data processing (hours or ever days of processing). Now I can open console on my machine, connect to VPS vi…

问题原文

原帖链接 · DaneSoul · CC BY-SA 3.0

I work on Linux Mint myself, have remote Ubuntu VPS server with root ssh access. I have script on server which makes long data processing (hours or ever days of processing).

Now I can open console on my machine, connect to VPS via ssh and run script - I see what script is doing in real time in my console (how much data processed, how much left and so on refreshes regulary on my console screen) - this works.

How can I do similar, but without dependencies of my local machine:

  1. Connect to server & run script
  2. Disconnect and left server to do his long processing work, while I can reboot my local machine or ever shut it down without affecting started server script execution.
  3. Have possibility to connect later again and see what is current status of process (same data it showed me in real time) without interrupting process.

已采纳解答

原帖链接 · 13dimitar · CC BY-SA 3.0

I think that screen is an ideal solution for you. How it works - you connect to your VPS, type screen, then run your script and detach from the shell (either close your terminal window, or press ctrl+a followed by ctrl+d)

Your script (and shell) will keep running in background. You can view the screen number by typing screen -ls. To restore your session and see the progress/result of your script, get the screen number with screen -ls and then connect to it with screen -r <screen number>. And that's it. After restoring, you can detach in the same manner again.

You can install screen on your VPS with apt-get install screen for Debian based distributions and yum install screen for RedHat based distros.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-01-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。