How run background python scripts in Linux

Let a python script running in linux server with no worries

It’s simple just open your terminal in Linux and use the command and close the terminal

nohup python3 -u yourpythonfile.py > out.out

the argument “> out.out” will create the log file …

Let a python script running in linux server with no worries

It’s simple just open your terminal in Linux and use the command and close the terminal

nohup python3 -u yourpythonfile.py > out.out

the argument “> out.out” will create the log file in the same folder that you run that command and when you open the terminal again to check how is the script you can use this command:

nano out.out

Now if you are using Google Cloud or AWS virtual machines, and you would like to shut down the machine after the execution to avoid extra costs $$ you can use this command:

nohup bash -c python3 -u yourpythonfile.py ; sudo shutdown -h now > out.out &

Image description


Print Share Comment Cite Upload Translate
APA
Paulo Mota | Sciencx (2024-03-28T17:13:23+00:00) » How run background python scripts in Linux. Retrieved from https://www.scien.cx/2021/11/30/how-run-background-python-scripts-in-linux/.
MLA
" » How run background python scripts in Linux." Paulo Mota | Sciencx - Tuesday November 30, 2021, https://www.scien.cx/2021/11/30/how-run-background-python-scripts-in-linux/
HARVARD
Paulo Mota | Sciencx Tuesday November 30, 2021 » How run background python scripts in Linux., viewed 2024-03-28T17:13:23+00:00,<https://www.scien.cx/2021/11/30/how-run-background-python-scripts-in-linux/>
VANCOUVER
Paulo Mota | Sciencx - » How run background python scripts in Linux. [Internet]. [Accessed 2024-03-28T17:13:23+00:00]. Available from: https://www.scien.cx/2021/11/30/how-run-background-python-scripts-in-linux/
CHICAGO
" » How run background python scripts in Linux." Paulo Mota | Sciencx - Accessed 2024-03-28T17:13:23+00:00. https://www.scien.cx/2021/11/30/how-run-background-python-scripts-in-linux/
IEEE
" » How run background python scripts in Linux." Paulo Mota | Sciencx [Online]. Available: https://www.scien.cx/2021/11/30/how-run-background-python-scripts-in-linux/. [Accessed: 2024-03-28T17:13:23+00:00]
rf:citation
» How run background python scripts in Linux | Paulo Mota | Sciencx | https://www.scien.cx/2021/11/30/how-run-background-python-scripts-in-linux/ | 2024-03-28T17:13:23+00:00
https://github.com/addpipe/simple-recorderjs-demo