How to keep my telegram bot always online? How do I keep my discord bot always active? How to make my telegram bot 24×7 online? How do I make my bot always online even after closing terminal or command prompt or shell?
I know my dear visitor what is happening with you, when you deploy your bot on any VPS server or cloud server, after that, when you run your bot using python command then it starts to work until your terminal or command prompt is turned on. But when your close your terminal or shell or command prompt, just after that, your bot stops to respond you. In simple word, it goes offline and do not reply until you again turn on your terminal. Don’t worry I’ll tell you a very simple and easy command by which you can easily make your bot 27×7 online. Just read this article till end.
How do I make my Telegram Bot or Discord Bot always active?
So to keep your bot always active through terminal/shell /command prompt, you need to follow our below steps:
1. Login to Terminal
First, login to your terminal/shell/command prompt by using ssh root@your_ip and password which is provided by your cloud platform.
2. Clone your Repository
After login, then clone your repository which you want to make online everytime using
git clone repository_url
Note: Repository should be public not in private, else you will have to provide your GitHub login details to clone your repository to the terminal.
3. Install Required libraries
After cloning the repository, make sure to install all required modules and libraries to make your code run properly without any errors. If you don’t know how to import all the required modules and libraries then execute below command:
pip3 install -r requirements.txt
4. Select Repository
After installing all the required libraries and modules, make sure to select the repository using this
ls
and then
cd repository_name
5. Install Screen Command
Then finally, install screen command by running below command:
sudo apt install screen
And then type screen and press enter and then press space two times.
6. Reselect Repository and Start your Bot
Then at last re select your repository using option 4 and then start your bot using your python command such as:
python3 -m bot
bash start.sh
Now it’s done. Now you can close your terminal/shell/command prompt. Now just go to your telegram bot or discord bot, and press /start, now you will see your bot is still active, still running even after closing the terminal. Note: you can install this screen command in any operating system such as windows, Linux, Ubuntu etc.
Now, if you want an article on how you can make your bot offline after using screen option, command below, we will write one more article about it. Let me know if you have any problems from above steps. Thankyou for reading till here!
13 Comments
Good
Good.
Good
Food time
Very nice 💯💯
Good
Good
its amazing website.
Good
Great work
Great
Thanku
Good