Skip to content

Instantly share code, notes, and snippets.

@tsengia
Created March 14, 2020 18:50
Show Gist options
  • Save tsengia/ea2fde9fd23019896eaeeac8f9d923e6 to your computer and use it in GitHub Desktop.
Save tsengia/ea2fde9fd23019896eaeeac8f9d923e6 to your computer and use it in GitHub Desktop.
Simple keep alive python3 script that makes a HTTP request every 2 minutes.
import time
import urllib.request
# Sleep for 2 minutes before sending the next keep alive
# This value is in seconds
DELAY = 120
# Url that we will be requesting.
URL = "https://example.com"
# NOTE: I dont know if caching will become a problem, if it does, trying mixing up the URL...
# Send the keep alive request to Google
def doKeepAlive():
global URL
contents = urllib.request.urlopen(URL).read()
print("PING")
while True:
doKeepAlive()
time.sleep(DELAY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment