Naive Algorist
Naive Algorist

Reputation: 71

How to run a python script continuosly once started on an online server without user interaction?

Few days back I wrote a Python script which retrieves running train information from a website and sends a SMS to a user specified number. It checks the train website, every 10 minutes in a loop, for any change in the running status of the train, if a change is found then the updated information is sent to the user via SMS.

Now this runs great with my PC kept on always, but I wanted to upload this script somewhere online so that it runs continously once started and sends SMSes even when the user is offline. This would facilitate live updates of the train while one is on the move.

I have checked the answers posted here: https://stackoverflow.com/questions/904977/somewhere-to-store-python-scripts-run-them-online But most of them are just online interpreters and about PythonAnywhere it would have done the work had it allowed connection to HTTP servers.

I have published it on GitHub at: https://github.com/naivealgorist/RTSly

Upvotes: 3

Views: 3295

Answers (4)

Alan Tom Binoy
Alan Tom Binoy

Reputation: 1

Try using the keep_alive module in python

Upvotes: 0

kindall
kindall

Reputation: 184191

Pretty much any dedicated or virtual hosting plan will let you do this. The machine belongs to you and you can do with it whatever you want, including leaving scripts running continually, or (better yet in your case) firing them off periodically via cron. Dreamhost has Linux VPSs starting at $15/month (there are many, many other vendors and I don't favor Dreamhost specifically, they were just a top Google result). Their smallest instance would be fine for what you want, plus you can use it for other things too. As it's hosted in a data center, it will likely have superior power and Internet uptime compared to anything you run at home.

Upvotes: 1

Steve Barnes
Steve Barnes

Reputation: 28370

Get a raspberry-pi, connect it up to your home internet and leave it running.

Upvotes: 1

Hans Then
Hans Then

Reputation: 11322

Have a look at google appengine https://appengine.google.com/ or amazon aws http://aws.amazon.com/. Both are platforms to host long running services. Appengine is easy to setup, but has some limitations. Amazon will require you to do your own system management and is somewhat more difficult to get started with, but allows you to do almost anything.

Upvotes: 1

Related Questions