简体   繁体   中英

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

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.

获取树莓派,将其连接到家庭互联网并保持运行。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM