yobro
yobro

Reputation: 21

Having problems running python script even when putty is closed

So basically, I have a bot I'm running, and I would like for it to keep running even when I exit putty.

I've tried using nohup python bot.py & but it still ends the python bot when I close the putty program. I've also tried using a run.sh file with /usr/bin/nohup bot.py & inside it. but it won't work :( is there something else I'm missing?

I have also made sure the run.sh is a executable as some other forums have suggested, and I still get can't open run

I'm kinda new to the linux terminal.

if you guys could help me out that would be awsome :)

Upvotes: 1

Views: 929

Answers (1)

Burhan Khalid
Burhan Khalid

Reputation: 174672

You need to detach the terminal so that when you exit, it is still running. You can use screen or tmux or some other multiplexer.

Here is how to do with screen:

screen -S mybot -m -d /usr/bin/python /path/to/bot.py 
  • -S give the session a name (this is useful if you want to attach later. screen -D -R mybot)
  • -m always create a new session
  • -d detach (launch the program, but then detach the terminal returning you to the prompt)

Upvotes: 2

Related Questions