Sagemaker Code Editor - Run Python script while computer is off

0

Hello,

I am trying to train a model using a Python script inside of the Sagemaker Code Editor. The script is started from the terminal. When I shut the computer down, the script continues to run for a couple of minutes longer, than hangs itsself. When I log back in the Code Editor, the script continues to run from the point it stopped. How can I run python scripts in the background, so that I do not have to keep the computer on and still see the output in the terminal?`

Thanks!

RaduM
asked 18 days ago105 views
2 Answers
1

ℹ️ You can execute a Python script in the background using the nohup command, which ensures that the process continues to run even after you exit the shell or terminal. However, it's important to note that nohup does not keep the script running if the computer on which it is executed is turned off or shut down. For more details on using the nohup command, you can refer to this guide: Nohup Command in Linux.

Example:

nohup python your_script.py > output.log &
profile picture
EXPERT
answered 16 days ago
0

Hello,

Please note that when we shut down, the terminal will not be able to record any output information. To continue to run the script and get the complete output even after you turn off your device, you can use "nohup" command.

nohup python script.py > output.log &

Please refer to https://paulorod7.com/running-a-python-script-in-terminal-without-losing-it-by-a-connection-drop for more details.

AWS
SUPPORT ENGINEER
answered 16 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions