How to run bot automatically?

C45HC0W

Regular Member
Joined
Jan 30, 2019
Messages
430
Reaction score
142
I build a bot which scraps a certain website and every time they post something i twitter it automatically. however, im a python programming noob and i have to manuel start the script every time.
How do I make this that it is always running like in a cloud? is it possible to run it out of googles drive?dont be so harsh to me. as I said im a noob. thank you very much!
 
You can run the script on a VPS and just keep it running forever on there.
 
Well i guess you need to Edit your Script so it will restart when crashed or after certain time
 
You can run the script on a VPS and just keep it running forever on there.

are there any free VPS options? amazon web services is only free for 12months i guess
 
Make a .exe programme then setup a windows task
 
Make a .exe programme then setup a windows task
thanks, but I dont want to have my computer on all the time. a vps is probably the best solution but its quite expensive...
 
Amazon free tier or Google cloud free tier. Free for 1 year both. For Google you can open a new account after 1 year, with same cc
 
You can use nohup for running it in background (if you have a linux vps/dedi)

e.g.
Code:
 nohup python_command  &

If you want the program to automatically start every time the server is restarted, try putting the command into crontab (crontab -e, follow this answer for example )

Btw, google drive is a "cloud storage space" so no, it won't run scripts for you; not normally atleast. Buy a cheap vps server ( for like $5 per mnth).
 
Last edited:
- Implement a while (true) { ... } loop into your code.
- Put a little delay at the end of the code block, e. g. wait for 60 seconds.
- Start the program inside the startup scripts of your server.
- Put a watchdog script around to notify you about possible crashes by email, SMS, ...
 
- Implement a while (true) { ... } loop into your code.
- Put a little delay at the end of the code block, e. g. wait for 60 seconds.
- Start the program inside the startup scripts of your server.
- Put a watchdog script around to notify you about possible crashes by email, SMS, ...


Endless while loop can end up pretty bad, but it might do the job. However, I would avoid that.

It would be better to use Cron Jobs that would schedule some tasks. They are used almost everywhere for similar tasks. (Daily mails, reports, actions...)

You can call scraping method every 5 minutes or 5 days, and not worrying about resources usage, memory leaks etc.
 
Use:

crontab ||
nohup ||
screen

&&

Linode ||
DigitalOcean
 
Buy a VPS, install supervisor and configure it how you want. You can find config samples everywhere.
 
Back
Top