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.

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.


You could also run the script in the background and access the output when you need it. My test script will be rather simple:

root@jump:~# cat test.sh
for ((i=0; i<=99999; i+=1)); do
    echo $i
    sleep 1

It just prints a number a second. To run it in the background, ill use at:

root@jump:~# at now
warning: commands will be executed using /bin/sh
at> /root/test.sh
at> <EOT>

Note: The EOT is done with Control&D. After that, let the script run, disconnect from the server. When you want to see the output, connect and find the PID of the process:

root@jump:~# ps aux | grep test
root      6312  0.0  2.1  18048  2836 ?        SN   13:08   0:00    /bin/bash /root/test.sh

And get the output. Replace 6312 with the PID of your process:

root@jump:~# tail -f /proc/6312/fd/1

fd/1 = stdout, fd/2 = stderr

  • 1
    while most likely working it might not be a good idea to use custom scripts for a solution you can easily use tmux and screen for, depending on the setup however you might be unable to install them so this is a valid "workaround" approach in my opinion. Feb 1 '17 at 13:38
  • 1
    Custom scripts? This solution does not use a script. It just does a tail. That's all. No need for terminal multiplexers in any way when basic unix commands can do the job.
    – embedded
    Feb 2 '17 at 18:29
  • 1
    you are right, my comment is partly wrong. Feb 3 '17 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.