Search code examples
pythonservergpuscheduled-tasks

Executing code on server while shutting down the computer


I have Python code that I want to run on a GPU server. Running it is time-consuming and sometimes, I get disconnected from the Internet or server and I have to re-run it. So, I need to let it run and shut down my computer. Is there any way?


Solution

  • You can use screen to maintain a session and achieve the goal that allows you to run the code on the server.

    Refer to this: https://www.gnu.org/software/screen/

    Some basic commands:

    • Create session named RunWork
    screen -S RunWork
    
    • List all sessions:
    screen -ls
    
    • Open a session
    screen -r SessionID
    

    ...