Skip to content

Instantly share code, notes, and snippets.

@sillygwailo
Created September 17, 2013 21:28
Show Gist options
  • Save sillygwailo/6600893 to your computer and use it in GitHub Desktop.
Save sillygwailo/6600893 to your computer and use it in GitHub Desktop.
Line in /etc/crontab
# At the top of the hour, start a timer (sleep) every two hours
# between 8 AM and 6 PM. That timer lasts for a random duration of
# up to two hours. When that timer runs out, run a script that
# sends a notification to my iPhone or Android device to remind me
# to drink a glass of water. (And only on weekdays.)
0 8,10,12,14,16,18 * * 1,2,3,4,5 root sleep `/usr/bin/expr $RANDOM \% 7200`; python /full/path/here/water.py
# 1. Creating an app to use with Pushover https://pushover.net/apps/build
# 2. Replace APP_TOKEN and USER_KEY with the app token and user key, respectively, from step #1.
# 3. Download the Pushover iOS or Android app and login from there.
#
# This is a slight modification of the example Python script at https://pushover.net/faq#library-python
# with the only change being the message sent over.
#
import httplib, urllib
conn = httplib.HTTPSConnection("api.pushover.net:443")
conn.request("POST", "/1/messages.json",
urllib.urlencode({
"token": "APP_TOKEN",
"user": "USER_KEY",
"message": "Time for a glass of water",
}), { "Content-type": "application/x-www-form-urlencoded" })
conn.getresponse()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment