Reputation: 3
So currently I'm trying to host a little bot I made in Python. It's meant to be running 24/7 so I tried Google cloud platform. I have a Ubuntu dist installed on a small scale VM server and I can run the bot perfectly. However when I exit out of my ssh session the python stops running. I've tried searching for solutions but I've found nothing.
So, how do I keep running python 24/7 on my Ubuntu VM?
Upvotes: 0
Views: 1383
Reputation: 2731
The typical solution for this would be either tmux
or screen
. I prefer tmux
, so I'll give instructions for that.
Start by installing tmux
sudo apt-get install tmux
Then start a session:
tmux new -s mybot
Then start your bot with whatever command you would normally use. Detach from the screen with Ctrl-a Ctr-d
. You can now exit your ssh session and the bot will still be running.
To reattach to the session (to shut down the bot or whatever), just run:
tmux attach -t mybot
Upvotes: 1