This content originally appeared on DEV Community and was authored by Paulo Mota
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 &
This content originally appeared on DEV Community and was authored by Paulo Mota
Paulo Mota | Sciencx (2021-11-30T11:54:20+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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.