Will
Will

Reputation: 5480

Executing Python script without hanging terminal

Now this question might seem like an questions like this one and this one.

However unfortunately the above solutions don't work for me. I need a way to execute a Python 3.4.3 script, leave it running when the terminal closes, and have it not hang in terminal and executed directly.

pi@raspberrypi:/var/www/html/mysite/scripts $ nohup python3 my.script.py &                                                                                                                                                          

The above runs the script, but it hangs in terminal, I cannot enter any other commands until I stop it, by pressing CTRL + C.

Is there a way to achieve something like this:

pi@raspberrypi:/var/www/html/mysite/scripts $ nohup python3 my.script.py &
pi@raspberrypi:/var/www/html/mysite/scripts $ 
(Now I enter more commands, despite the script still running)

I hope I have provided enough information, hopefully you can help me, thanks!

Upvotes: 1

Views: 1732

Answers (2)

haphi
haphi

Reputation: 84

If the ampersand doesn't work, you can use a terminal multiplexer like GNU screen or tmux for your purpose.

Upvotes: 0

mousetail
mousetail

Reputation: 8010

Based on a quick google search, I found

start /b python3 my.script.py

for windows or

python3 my.script.py &

on lunix (bash).

Upvotes: 1

Related Questions