Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Batch download on an ssh session

I need to download some satellite images from sentinel2 via python script. I have already tested locally on a small amount of files and the script works correctly. Now I should run this script on an ssh session. My question is, how do I leave the script running (downloading) even if I close the ssh connection? Is it sufficient to launch the script in background (python3 main.py &) ?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

There are many tools for jobs like this: for example check this thread.

You can start with screen.

$ screen  # initiates a screen session

In the screen session, do:

$ python my_scripts.py

When the script is running, you can detach from the screen session with Ctrl-A+D.

The script will run in "background" and you can leave your current ssh session.

For batch downloads, you can shoot-up multiple screen sessions. You could assign a name for each screen when you initiate the session. In this way you can run multiple scripts, one in each session.

To check opened sessions:

$ screen -ls
There are screens on:
    96185.pts-5.xxxxx-xxxx-xxx-xx   (2022年07月01日 17时39分06秒) (Detached)
    95231.pts-5.xxxxx-xxxx-xxx-xx   (2022年07月01日 17时20分40秒) (Detached)

And to reattach to a specific session:

$ screen -r 96185

But before you do all of that, you might want to check there’re enough resource (disk space, bandwidth, etc.).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading