Run the task in the background on the sshed server

Overview

I'm feeling a lot better now, but I've been working more remotely, and more and more operations such as machine learning are being performed on remote servers. The reason is that my laptop isn't very specs, but it doesn't have enough specs. Of course it is good to use google colab, but if you do not operate it for a long time, it will time out and the performance of the GPU that can be used is limited.

I was always typing commands on the server I sshed to, but I kept the connection in order to keep the process sshed alive. .. But when I thought about it, I didn't have to do that at all.

manner

First make ssh connection easy

https://qiita.com/kenmaro/items/a548a302228029c5c870 As explained in detail here, by setting ssh authentication and editing `` `~ / .ssh / config, For example, an ssh connection to my_remote_pc```

ssh my_remote_pc

You will be able to connect to ssh very easily.

Process background execution

Also, many people may have done the command background locally. For example, if you want to run ``` python main.py in the background, just add &` `` at the end of the command.

python main.py &

Do the top two at the same time

If you mix the above two, you can run it in the background on the server you sshed to. Now, even if you disconnect the ssh connection, the process will run on the remote server.

It's easy to do, `ssh <***>" <***> & "`. In the previous example,

ssh my_remote_pc "python main.py &"

Only this.

Now you don't have to bother checking the ssh connection to see if the process is running.

I think most people take it for granted, but I'm sure there are people like me who are doing something inconvenient and useless, so I hope it helps.

Postscript

Use the screen command

This was much easier to do.

You only need about 3 commands to remember.

screen

First, create a virtual terminal (called a session).

Then perform some task.

ctrl-a --> d

Leave the terminal created by this command. (Detach)

screen -ls

To list the sessions in

screen -r <session id>

Reconnect with.

Around here.

end.

Recommended Posts

Run the task in the background on the sshed server
The day when the flask server running on linux on AWS was semi-persistent (running in the background)
Run CGI written in python on Sakura's rental server
Run background job in fabric
Test.py is not reflected on the web server in Python3.
Run a Linux server on GCP
run uwsgi server in uwsgi-gevent mode
Run TensorFlow2 on a VPS server
Notes on using matplotlib on the server
Run the output code on the local web server as "A, pretending to be B" in python
Save the audio data acquired by the browser in wav format on the server
Start the web server in the current directory
Insufficient var space on the mail server
Run AzureKinect in Python on Christmas Eve.
Run the Python interpreter in a script
Looking back on 2016 in the Crystal language
Deploy and use the prediction model created in Python on SQL Server
Run Jupyter notebook on a remote server
Run Python in C ++ on Visual Studio 2017
Publish the current directory on the web server
Run python wsgi server on NGINX Unit
Log in to the remote server with SSH
Drawing tips with matplotlib on the server side
Run Python YOLOv3 in C ++ on Visual Studio 2017
Run yolov4 "for the time being" on windows
Until you run the changefinder sample in python
[Mac] Run the RealSense D415 sample in Python
Launch an HTTP server in the current directory
Remotely open Jupyter notebook launched on the server
Run Laravel-admin on Golang PHP application server RoadRunner
TensorFlow: Run data learned in Python on Android
[CGI] Run the Python program on the server with Vue.js + axios and get the output data
The most crude CORS support method on aiohttp Server
Run the flask app on Cloud9 and Apache Httpd
Notes on transactions in the Java client library in the datastore
How to run the Ansible module added in Ansible Tower
Register a task in cron for the first time
Implement Sign In With Google on the backend side
Set up a free server on AWS in 30 minutes
Difference in results depending on the argument of multiprocess.Process
Write a log-scale histogram on the x-axis in python
Execute the command on the web server and display the result
Until you run server Django in Visual Studio Code
How to run Django on IIS on a Windows server
Install django on python + anaconda and start the server
The image is displayed in the local development environment, but the image is not displayed on the remote server of VPS
"Deep Learning from scratch" Self-study memo (No. 14) Run the program in Chapter 4 on Google Colaboratory